public SqlTimestampWithTimeZone(long millisUtc, TimeZone timeZone) { this.millisUtc = millisUtc; this.timeZoneKey = TimeZoneKey.getTimeZoneKey(timeZone.getID()); }
@Test public void testZoneKeyLookup() { for (TimeZoneKey timeZoneKey : TimeZoneKey.getTimeZoneKeys()) { assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getKey()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toUpperCase(ENGLISH)), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toLowerCase(ENGLISH)), timeZoneKey); } }
public SqlTimeWithTimeZone(long millisUtc, TimeZone timeZone) { this.millisUtc = millisUtc; this.timeZoneKey = TimeZoneKey.getTimeZoneKey(timeZone.getID()); }
@Test public void testZoneKeyLookup() { for (TimeZoneKey timeZoneKey : TimeZoneKey.getTimeZoneKeys()) { assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getKey()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toUpperCase(ENGLISH)), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toLowerCase(ENGLISH)), timeZoneKey); } }
public void assertTimeZoneNotSupported(String zoneId) { try { TimeZoneKey.getTimeZoneKey(zoneId); fail("expect TimeZoneNotSupportedException"); } catch (TimeZoneNotSupportedException e) { // expected } } }
public void assertTimeZoneNotSupported(String zoneId) { try { TimeZoneKey.getTimeZoneKey(zoneId); fail("expect TimeZoneNotSupportedException"); } catch (TimeZoneNotSupportedException e) { // expected } } }
@Test public void testCastToTimeWithTimeZoneDSTIsNotAppliedWhenTimeCrossesDST() { // Australia/Sydney will switch DST a second after session start // For simplicity we have to use time zone that is going forward when entering DST zone with 1970-01-01 Session session = Session.builder(this.session) .setTimeZoneKey(getTimeZoneKey("Australia/Sydney")) .setStartTime(new DateTime(2017, 10, 1, 1, 59, 59, 999, getDateTimeZone(getTimeZoneKey("Australia/Sydney"))).getMillis()) .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(session)) { localAssertions.assertFunctionString("cast(TIME '12:00:00.000' as time with time zone)", TIME_WITH_TIME_ZONE, "12:00:00.000 Australia/Sydney"); } }
protected TestTimeWithTimeZoneBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(getTimeZoneKey("+06:09")) .build()); }
protected TestTimeWithTimeZoneBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(getTimeZoneKey("+06:09")) .build()); }
@ScalarFunction(value = "at_timezone", hidden = true) @LiteralParameters("x") @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long timeAtTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long timeWithTimeZone, @SqlType("varchar(x)") Slice zoneId) { return timeAtTimeZone(session, timeWithTimeZone, getTimeZoneKey(zoneId.toStringUtf8())); }
@ScalarFunction(value = "at_timezone", hidden = true) @LiteralParameters("x") @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long timeAtTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long timeWithTimeZone, @SqlType("varchar(x)") Slice zoneId) { return timeAtTimeZone(session, timeWithTimeZone, getTimeZoneKey(zoneId.toStringUtf8())); }
public TestLambdaExpression() { this(testSessionBuilder().setTimeZoneKey(getTimeZoneKey("Pacific/Kiritimati")).build()); }
public TestArrayTransformFunction() { super(testSessionBuilder().setTimeZoneKey(getTimeZoneKey("Pacific/Kiritimati")).build()); }
public TestArrayReduceFunction() { super(testSessionBuilder().setTimeZoneKey(getTimeZoneKey("Pacific/Kiritimati")).build()); }
private static SqlTimeWithTimeZone toTimeWithTimeZone(OffsetTime offsetTime) { return new SqlTimeWithTimeZone( millisUtc(offsetTime), TimeZoneKey.getTimeZoneKey(offsetTime.getOffset().getId())); }
private static SqlTimeWithTimeZone toTimeWithTimeZone(OffsetTime offsetTime) { return new SqlTimeWithTimeZone( millisUtc(offsetTime), TimeZoneKey.getTimeZoneKey(offsetTime.getOffset().getId())); }
private void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) { Session localSession = testSessionBuilder() .setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")) .setStartTime(date.getMillis()) .setSystemProperty("legacy_timestamp", "false") .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) { localAssertions.assertFunction(timeLiteral, expectedType, expected); localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral)); } }
private void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) { Session localSession = testSessionBuilder() .setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")) .setStartTime(date.getMillis()) .setSystemProperty("legacy_timestamp", "true") .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) { localAssertions.assertFunction(timeLiteral, expectedType, expected); localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral)); } }
private void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) { Session localSession = testSessionBuilder() .setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")) .setStartTime(date.getMillis()) .setSystemProperty("legacy_timestamp", "true") .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) { localAssertions.assertFunction(timeLiteral, expectedType, expected); localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral)); } }
private void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) { Session localSession = testSessionBuilder() .setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")) .setStartTime(date.getMillis()) .setSystemProperty("legacy_timestamp", "false") .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) { localAssertions.assertFunction(timeLiteral, expectedType, expected); localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral)); } }