Package com.facebook.presto.spi.type

Examples of com.facebook.presto.spi.type.SqlDate


    @Test
    public void testCastToDate()
            throws Exception
    {
        assertFunction("cast(TIMESTAMP '2001-1-22 03:04:05.321 +07:09' as date)",
                new SqlDate(new LocalDate(2001, 1, 22).toDateMidnight(getDateTimeZone(session.getTimeZoneKey())).getMillis(), session.getTimeZoneKey()));
    }
View Full Code Here


    @Test
    public void testCastToDate()
            throws Exception
    {
        assertFunction("cast(TIMESTAMP '2001-1-22 03:04:05.321' as date)", new SqlDate(new LocalDate(2001, 1, 22).toDateMidnight(DATE_TIME_ZONE).getMillis(), TIME_ZONE_KEY));
    }
View Full Code Here

    }

    @Test
    public void testDatePlusInterval()
    {
        assertFunction("DATE '2001-1-22' + INTERVAL '3' day", new SqlDate(new DateTime(2001, 1, 25, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
        assertFunction("INTERVAL '3' day + DATE '2001-1-22'", new SqlDate(new DateTime(2001, 1, 25, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
        assertFunction("DATE '2001-1-22' + INTERVAL '3' month", new SqlDate(new DateTime(2001, 4, 22, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
        assertFunction("INTERVAL '3' month + DATE '2001-1-22'", new SqlDate(new DateTime(2001, 4, 22, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
        assertFunction("DATE '2001-1-22' + INTERVAL '3' year", new SqlDate(new DateTime(2004, 1, 22, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
        assertFunction("INTERVAL '3' year + DATE '2001-1-22'", new SqlDate(new DateTime(2004, 1, 22, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));

        try {
            functionAssertions.tryEvaluate("DATE '2001-1-22' + INTERVAL '3' hour");
            fail("Expected IllegalArgumentException");
        }
View Full Code Here

    }

    @Test
    public void testDateMinusInterval()
    {
        assertFunction("DATE '2001-1-22' - INTERVAL '3' day", new SqlDate(new DateTime(2001, 1, 19, 0, 0, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));

        try {
            functionAssertions.tryEvaluate("DATE '2001-1-22' - INTERVAL '3' hour");
            fail("Expected IllegalArgumentException");
        }
View Full Code Here

    @Test
    public void testLiteral()
            throws Exception
    {
        assertFunction("DATE '2001-1-22'", new SqlDate(new LocalDate(2001, 1, 22).toDateMidnight(getDateTimeZone(TIME_ZONE_KEY)).getMillis(), TIME_ZONE_KEY));
    }
View Full Code Here

    @Test
    public void testGreatest()
            throws Exception
    {
        assertFunction("greatest(DATE '2013-03-30', DATE '2012-05-23')", new SqlDate(new LocalDate(2013, 3, 30).toDateMidnight(getDateTimeZone(TIME_ZONE_KEY)).getMillis(), TIME_ZONE_KEY));
    }
View Full Code Here

    @Test
    public void testLeast()
            throws Exception
    {
        assertFunction("least(DATE '2013-03-30', DATE '2012-05-23')", new SqlDate(new LocalDate(2012, 5, 23).toDateMidnight(getDateTimeZone(TIME_ZONE_KEY)).getMillis(), TIME_ZONE_KEY));
    }
View Full Code Here

        functionAssertions.assertFunction(projection, expected);
    }

    private SqlDate toDate(long milliseconds)
    {
        return new SqlDate(milliseconds, session.getTimeZoneKey());
    }
View Full Code Here

        return new SqlDate(milliseconds, session.getTimeZoneKey());
    }

    private SqlDate toDate(DateTime dateDate)
    {
        return new SqlDate(dateDate.getMillis(), session.getTimeZoneKey());
    }
View Full Code Here

        functionAssertions.assertFunction(projection, expected);
    }

    private SqlDate toDate(long milliseconds)
    {
        return new SqlDate(milliseconds, session.getTimeZoneKey());
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.type.SqlDate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.