From bab25677bb391e36ca77792fefbd57352bd5bae9 Mon Sep 17 00:00:00 2001 From: Kenshin Okinaka Date: Thu, 3 Dec 2026 23:14:35 +0900 Subject: [PATCH] test(athena): share a types helper in the date-time function tests (#10071) fromIso8601TimestampIsTypedTimestampWithTimeZone and withTimezoneIsTypedTimestampWithTimeZone repeated the same DESCRIBE query with only the SQL changed. A types(sql) helper next to row(...) now serves both; the assertions are unchanged. --- ...teTimeFunctionsSidecarIntegrationTest.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/test/java/io/floci/aws/services/athena/AthenaTrinoDateTimeFunctionsSidecarIntegrationTest.java b/src/test/java/io/floci/aws/services/athena/AthenaTrinoDateTimeFunctionsSidecarIntegrationTest.java index 7f5fee0048..8b1faa1dd5 100644 --- a/src/test/java/io/floci/aws/services/athena/AthenaTrinoDateTimeFunctionsSidecarIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/athena/AthenaTrinoDateTimeFunctionsSidecarIntegrationTest.java @@ -36,6 +36,13 @@ class AthenaTrinoDateTimeFunctionsSidecarIntegrationTest { return duck.query(TrinoSqlCompatibility.translate(trinoSql), TrinoSqlCompatibility.FUNCTION_MACROS).getFirst(); } + private List types(String trinoSql) { + return duck.query("DESCRIBE " + TrinoSqlCompatibility.translate(trinoSql), TrinoSqlCompatibility.FUNCTION_MACROS) + .stream() + .map(column -> AthenaService.athenaType(String.valueOf(column.get("column_type")))) + .toList(); + } + @Test void fromIso8601TimestampReadsADateTimeWithAnOffsetAsThatInstant() { Map row = row("SELECT " @@ -128,13 +135,7 @@ class AthenaTrinoDateTimeFunctionsSidecarIntegrationTest { @Test void fromIso8601TimestampIsTypedTimestampWithTimeZone() { - List types = duck.query("DESCRIBE " + TrinoSqlCompatibility.translate( - "SELECT from_iso8601_timestamp('2026-12-02T08:22:50Z') AS t"), TrinoSqlCompatibility.FUNCTION_MACROS) - .stream() - .map(column -> AthenaService.athenaType(String.valueOf(column.get("column_type")))) - .toList(); - - assertEquals(List.of("timestamp with time zone"), types); + assertEquals(List.of("timestamp with time zone"), types("SELECT from_iso8601_timestamp('2026-12-02T08:22:50Z') AS t")); } @Test @@ -151,13 +152,7 @@ class AthenaTrinoDateTimeFunctionsSidecarIntegrationTest { @Test void withTimezoneIsTypedTimestampWithTimeZone() { - List types = duck.query("DESCRIBE " + TrinoSqlCompatibility.translate( - "SELECT with_timezone(TIMESTAMP '2026-12-02 08:22:50', 'UTC') AS t"), TrinoSqlCompatibility.FUNCTION_MACROS) - .stream() - .map(column -> AthenaService.athenaType(String.valueOf(column.get("column_type")))) - .toList(); - - assertEquals(List.of("timestamp with time zone"), types); + assertEquals(List.of("timestamp with time zone"), types("SELECT with_timezone(TIMESTAMP '2026-12-02 08:22:50', 'UTC') AS t")); } /**