Search in sources :

Example 1 with FunctionAssertions

use of io.prestosql.operator.scalar.FunctionAssertions in project hetu-core by openlookeng.

the class TestDateTimeOperators method testTimeRepresentationOnDate.

private static void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) {
    Session localSession = testSessionBuilder().setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")).setStartTime(date.getMillis()).build();
    try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) {
        localAssertions.assertFunction(timeLiteral, expectedType, expected);
        localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral));
    }
}
Also used : FunctionAssertions(io.prestosql.operator.scalar.FunctionAssertions) Session(io.prestosql.Session)

Example 2 with FunctionAssertions

use of io.prestosql.operator.scalar.FunctionAssertions in project hetu-core by openlookeng.

the class TestExpressionCompiler method setupClass.

@BeforeClass
public void setupClass() {
    Logging.initialize();
    if (PARALLEL) {
        executor = listeningDecorator(newFixedThreadPool(getRuntime().availableProcessors() * 2, daemonThreadsNamed("completer-%s")));
    } else {
        executor = newDirectExecutorService();
    }
    functionAssertions = new FunctionAssertions();
}
Also used : FunctionAssertions(io.prestosql.operator.scalar.FunctionAssertions) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with FunctionAssertions

use of io.prestosql.operator.scalar.FunctionAssertions in project hetu-core by openlookeng.

the class TestTimeBase method testCastToTimeWithTimeZoneWithTZWithRulesChanged.

@Test
public void testCastToTimeWithTimeZoneWithTZWithRulesChanged() {
    TimeZoneKey timeZoneThatChangedSince1970 = getTimeZoneKey("Asia/Kathmandu");
    DateTimeZone dateTimeZoneThatChangedSince1970 = getDateTimeZone(timeZoneThatChangedSince1970);
    Session session = Session.builder(this.session).setTimeZoneKey(timeZoneThatChangedSince1970).build();
    try (FunctionAssertions localAssertions = new FunctionAssertions(session)) {
        localAssertions.assertFunction("cast(TIME '03:04:05.321' as time with time zone)", TIME_WITH_TIME_ZONE, new SqlTimeWithTimeZone(new DateTime(1970, 1, 1, 3, 4, 5, 321, dateTimeZoneThatChangedSince1970).getMillis(), dateTimeZoneThatChangedSince1970.toTimeZone()));
    }
}
Also used : SqlTimeWithTimeZone(io.prestosql.spi.type.SqlTimeWithTimeZone) FunctionAssertions(io.prestosql.operator.scalar.FunctionAssertions) TimeZoneKey(io.prestosql.spi.type.TimeZoneKey) TimeZoneKey.getTimeZoneKey(io.prestosql.spi.type.TimeZoneKey.getTimeZoneKey) DateTimeZone(org.joda.time.DateTimeZone) DateTimeZoneIndex.getDateTimeZone(io.prestosql.spi.util.DateTimeZoneIndex.getDateTimeZone) DateTime(org.joda.time.DateTime) TestingSession(io.prestosql.testing.TestingSession) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

FunctionAssertions (io.prestosql.operator.scalar.FunctionAssertions)3 Session (io.prestosql.Session)2 SqlTimeWithTimeZone (io.prestosql.spi.type.SqlTimeWithTimeZone)1 TimeZoneKey (io.prestosql.spi.type.TimeZoneKey)1 TimeZoneKey.getTimeZoneKey (io.prestosql.spi.type.TimeZoneKey.getTimeZoneKey)1 DateTimeZoneIndex.getDateTimeZone (io.prestosql.spi.util.DateTimeZoneIndex.getDateTimeZone)1 TestingSession (io.prestosql.testing.TestingSession)1 DateTime (org.joda.time.DateTime)1 DateTimeZone (org.joda.time.DateTimeZone)1 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1