Skip to content

Commit cb525e5

Browse files
committed
Add tests for precisions 7-9 for timestamp types
1 parent fa0ba05 commit cb525e5

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

plugin/trino-exasol/src/test/java/io/trino/plugin/exasol/TestExasolTypeMapping.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ private void testTimestamp(ZoneId sessionZone)
313313
.addRoundTrip("timestamp(9)", "TIMESTAMP '3030-03-03 12:34:56.123456789'", createTimestampType(9), "TIMESTAMP '3030-03-03 12:34:56.123456789'")
314314
.addRoundTrip("timestamp", "TIMESTAMP '3030-03-03 12:34:56.123'", createTimestampType(3), "TIMESTAMP '3030-03-03 12:34:56.123'")
315315
.addRoundTrip("timestamp(5)", "TIMESTAMP '3030-03-03 12:34:56.12345'", createTimestampType(5), "TIMESTAMP '3030-03-03 12:34:56.12345'")
316+
.addRoundTrip("timestamp(6)", "TIMESTAMP '3030-03-03 12:34:56.123456'", createTimestampType(6), "TIMESTAMP '3030-03-03 12:34:56.123456'")
317+
.addRoundTrip("timestamp(7)", "TIMESTAMP '3030-03-03 12:34:56.1234567'", createTimestampType(7), "TIMESTAMP '3030-03-03 12:34:56.1234567'")
318+
.addRoundTrip("timestamp(8)", "TIMESTAMP '3030-03-03 12:34:56.12345678'", createTimestampType(8), "TIMESTAMP '3030-03-03 12:34:56.12345678'")
316319
.addRoundTrip("timestamp(9)", "TIMESTAMP '3030-03-03 12:34:56.123456789'", createTimestampType(9), "TIMESTAMP '3030-03-03 12:34:56.123456789'")
317320
.addRoundTrip("timestamp(0)", "TIMESTAMP '2017-07-01'", createTimestampType(0), "TIMESTAMP '2017-07-01'") // summer on northern hemisphere (possible DST)
318321
.addRoundTrip("timestamp(0)", "TIMESTAMP '2017-01-01'", createTimestampType(0), "TIMESTAMP '2017-01-01'") // winter on northern hemisphere (possible DST on southern hemisphere)
@@ -350,29 +353,32 @@ private void testTimestampWithJvmTimeZone()
350353
.addRoundTrip("cast(col_6 AT TIME ZONE 'UTC' AS timestamp with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '2018-03-25 03:17:17.000'", createTimestampWithTimeZoneType(3), "TIMESTAMP '2018-03-25 09:17:17.000 UTC'")
351354
.addRoundTrip("cast(col_7 AT TIME ZONE 'UTC' AS timestamp with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '1986-01-01 00:13:07.000'", createTimestampWithTimeZoneType(3), "TIMESTAMP '1986-01-01 07:13:07.000 UTC'")
352355

353-
// timestamp with precision 6 examples
356+
// timestamp with precision 6-9 examples
354357
.addRoundTrip("cast(col_8 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2019-03-18 10:01:17.987654'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2019-03-18 16:01:17.987654 UTC'")
355358
.addRoundTrip("cast(col_9 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2018-10-28 01:33:17.456789'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2018-10-28 07:33:17.456789 UTC'")
356359
.addRoundTrip("cast(col_10 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2018-10-28 03:33:33.333333'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2018-10-28 09:33:33.333333 UTC'")
357360
.addRoundTrip("cast(col_11 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '1970-01-01 00:13:42.000000'", createTimestampWithTimeZoneType(6), "TIMESTAMP '1970-01-01 07:13:42.000000 UTC'")
358361
.addRoundTrip("cast(col_12 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2018-04-01 02:13:55.123456'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2018-04-01 08:13:55.123456 UTC'")
359362
.addRoundTrip("cast(col_13 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2018-03-25 03:17:17.000000'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2018-03-25 09:17:17.000000 UTC'")
360363
.addRoundTrip("cast(col_14 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '1986-01-01 00:13:07.000000'", createTimestampWithTimeZoneType(6), "TIMESTAMP '1986-01-01 07:13:07.000000 UTC'")
364+
.addRoundTrip("cast(col_15 AT TIME ZONE 'UTC' AS timestamp(7) with time zone)", "timestamp(7) with local time zone", "TIMESTAMP '1986-01-01 00:13:07.1234567'", createTimestampWithTimeZoneType(7), "TIMESTAMP '1986-01-01 07:13:07.1234567 UTC'")
365+
.addRoundTrip("cast(col_16 AT TIME ZONE 'UTC' AS timestamp(8) with time zone)", "timestamp(8) with local time zone", "TIMESTAMP '1986-01-01 00:13:07.12345678'", createTimestampWithTimeZoneType(8), "TIMESTAMP '1986-01-01 07:13:07.12345678 UTC'")
366+
.addRoundTrip("cast(col_17 AT TIME ZONE 'UTC' AS timestamp(9) with time zone)", "timestamp(9) with local time zone", "TIMESTAMP '1986-01-01 00:13:07.123456789'", createTimestampWithTimeZoneType(9), "TIMESTAMP '1986-01-01 07:13:07.123456789 UTC'")
361367

362368
// tests for other precisions (0-5 and some 1's)
363-
.addRoundTrip("cast(col_15 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(0) with local time zone", "TIMESTAMP '1970-01-01 00:00:01'", createTimestampWithTimeZoneType(0), "TIMESTAMP '1970-01-01 07:00:01 UTC'")
364-
.addRoundTrip("cast(col_16 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.1'", createTimestampWithTimeZoneType(1), "TIMESTAMP '1970-01-01 07:00:01.1 UTC'")
365-
.addRoundTrip("cast(col_17 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.9'", createTimestampWithTimeZoneType(1), "TIMESTAMP '1970-01-01 07:00:01.9 UTC'")
366-
.addRoundTrip("cast(col_18 AT TIME ZONE 'UTC' AS timestamp(2) with time zone)", "timestamp(2) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.12'", createTimestampWithTimeZoneType(2), "TIMESTAMP '1970-01-01 07:00:01.12 UTC'")
367-
.addRoundTrip("cast(col_19 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.123'", createTimestampWithTimeZoneType(3), "TIMESTAMP '1970-01-01 07:00:01.123 UTC'")
368-
.addRoundTrip("cast(col_20 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.999'", createTimestampWithTimeZoneType(3), "TIMESTAMP '1970-01-01 07:00:01.999 UTC'")
369-
.addRoundTrip("cast(col_21 AT TIME ZONE 'UTC' AS timestamp(4) with time zone)", "timestamp(4) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.1234'", createTimestampWithTimeZoneType(4), "TIMESTAMP '1970-01-01 07:00:01.1234 UTC'")
370-
.addRoundTrip("cast(col_22 AT TIME ZONE 'UTC' AS timestamp(5) with time zone)", "timestamp(5) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.12345'", createTimestampWithTimeZoneType(5), "TIMESTAMP '1970-01-01 07:00:01.12345 UTC'")
371-
.addRoundTrip("cast(col_23 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.1'", createTimestampWithTimeZoneType(1), "TIMESTAMP '2020-09-27 17:34:56.1 UTC'")
372-
.addRoundTrip("cast(col_24 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.9'", createTimestampWithTimeZoneType(1), "TIMESTAMP '2020-09-27 17:34:56.9 UTC'")
373-
.addRoundTrip("cast(col_25 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.123'", createTimestampWithTimeZoneType(3), "TIMESTAMP '2020-09-27 17:34:56.123 UTC'")
374-
.addRoundTrip("cast(col_26 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.999'", createTimestampWithTimeZoneType(3), "TIMESTAMP '2020-09-27 17:34:56.999 UTC'")
375-
.addRoundTrip("cast(col_27 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.123456'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2020-09-27 17:34:56.123456 UTC'");
369+
.addRoundTrip("cast(col_18 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(0) with local time zone", "TIMESTAMP '1970-01-01 00:00:01'", createTimestampWithTimeZoneType(0), "TIMESTAMP '1970-01-01 07:00:01 UTC'")
370+
.addRoundTrip("cast(col_19 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.1'", createTimestampWithTimeZoneType(1), "TIMESTAMP '1970-01-01 07:00:01.1 UTC'")
371+
.addRoundTrip("cast(col_20 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.9'", createTimestampWithTimeZoneType(1), "TIMESTAMP '1970-01-01 07:00:01.9 UTC'")
372+
.addRoundTrip("cast(col_21 AT TIME ZONE 'UTC' AS timestamp(2) with time zone)", "timestamp(2) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.12'", createTimestampWithTimeZoneType(2), "TIMESTAMP '1970-01-01 07:00:01.12 UTC'")
373+
.addRoundTrip("cast(col_22 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.123'", createTimestampWithTimeZoneType(3), "TIMESTAMP '1970-01-01 07:00:01.123 UTC'")
374+
.addRoundTrip("cast(col_23 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.999'", createTimestampWithTimeZoneType(3), "TIMESTAMP '1970-01-01 07:00:01.999 UTC'")
375+
.addRoundTrip("cast(col_24 AT TIME ZONE 'UTC' AS timestamp(4) with time zone)", "timestamp(4) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.1234'", createTimestampWithTimeZoneType(4), "TIMESTAMP '1970-01-01 07:00:01.1234 UTC'")
376+
.addRoundTrip("cast(col_25 AT TIME ZONE 'UTC' AS timestamp(5) with time zone)", "timestamp(5) with local time zone", "TIMESTAMP '1970-01-01 00:00:01.12345'", createTimestampWithTimeZoneType(5), "TIMESTAMP '1970-01-01 07:00:01.12345 UTC'")
377+
.addRoundTrip("cast(col_26 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.1'", createTimestampWithTimeZoneType(1), "TIMESTAMP '2020-09-27 17:34:56.1 UTC'")
378+
.addRoundTrip("cast(col_27 AT TIME ZONE 'UTC' AS timestamp(1) with time zone)", "timestamp(1) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.9'", createTimestampWithTimeZoneType(1), "TIMESTAMP '2020-09-27 17:34:56.9 UTC'")
379+
.addRoundTrip("cast(col_28 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.123'", createTimestampWithTimeZoneType(3), "TIMESTAMP '2020-09-27 17:34:56.123 UTC'")
380+
.addRoundTrip("cast(col_29 AT TIME ZONE 'UTC' AS timestamp(3) with time zone)", "timestamp(3) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.999'", createTimestampWithTimeZoneType(3), "TIMESTAMP '2020-09-27 17:34:56.999 UTC'")
381+
.addRoundTrip("cast(col_30 AT TIME ZONE 'UTC' AS timestamp(6) with time zone)", "timestamp(6) with local time zone", "TIMESTAMP '2020-09-27 12:34:56.123456'", createTimestampWithTimeZoneType(6), "TIMESTAMP '2020-09-27 17:34:56.123456 UTC'");
376382

377383
test.execute(getQueryRunner(), exasolCreateAndInsert(TEST_SCHEMA + "." + "test_timestamp"));
378384
}
@@ -384,7 +390,7 @@ void testUnsupportedTimestampValues()
384390
// Too early
385391
assertExasolQueryFails(
386392
"INSERT INTO " + table.getName() + " VALUES (TIMESTAMP '0000-12-31 23:59:59.999999')",
387-
"data exception - invalid timestamp value");
393+
"data exception - invalid date value");
388394

389395
// Too late
390396
assertExasolQueryFails(

0 commit comments

Comments
 (0)