From 5b270e4ba8d3f685fce311c571c5c3956d1d66a0 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Fri, 27 May 2022 14:21:56 +0200 Subject: [PATCH 1/3] Add time/timestamp 6 connector smoke test coverage --- .../plugin/accumulo/TestAccumuloConnectorTest.java | 3 +++ .../cassandra/TestCassandraConnectorTest.java | 5 +++++ .../clickhouse/BaseClickHouseConnectorTest.java | 3 +++ .../deltalake/BaseDeltaLakeMinioConnectorTest.java | 7 ++++++- .../trino/plugin/hive/BaseHiveConnectorTest.java | 8 +++++++- .../plugin/iceberg/BaseIcebergConnectorTest.java | 14 ++++---------- .../plugin/kudu/AbstractKuduConnectorTest.java | 5 ++++- .../plugin/mariadb/BaseMariaDbConnectorTest.java | 6 ++++-- .../plugin/mongodb/BaseMongoConnectorTest.java | 13 +++++++++++++ .../trino/plugin/mysql/BaseMySqlConnectorTest.java | 3 ++- .../plugin/oracle/BaseOracleConnectorTest.java | 7 +++++-- .../plugin/phoenix/TestPhoenixConnectorTest.java | 7 +++++-- .../plugin/phoenix5/TestPhoenixConnectorTest.java | 7 +++++-- .../raptor/legacy/BaseRaptorConnectorTest.java | 3 +++ .../singlestore/TestSingleStoreConnectorTest.java | 3 ++- .../sqlserver/BaseSqlServerConnectorTest.java | 3 ++- .../java/io/trino/testing/BaseConnectorTest.java | 3 +++ 17 files changed, 76 insertions(+), 24 deletions(-) diff --git a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java index 1c108b17b78a..e7b197493499 100644 --- a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java +++ b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java @@ -304,7 +304,10 @@ protected Optional filterDataMappingSmokeTestData(DataMapp { String typeName = dataMappingTestSetup.getTrinoTypeName(); if (typeName.startsWith("decimal(") + || typeName.equals("time(6)") + || typeName.equals("timestamp(6)") || typeName.equals("timestamp(3) with time zone") + || typeName.equals("timestamp(6) with time zone") || typeName.startsWith("char(")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java index 18c5f24d47df..25b522e20b12 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java @@ -156,6 +156,11 @@ protected Optional filterDataMappingSmokeTestData(DataMapp // TODO this should either work or fail cleanly return Optional.empty(); } + if (typeName.equals("time(6)") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(6) with time zone")) { + return Optional.of(dataMappingTestSetup.asUnsupported()); + } return Optional.of(dataMappingTestSetup); } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java index 73b3dd66aec9..c385d023ca55 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java @@ -496,8 +496,11 @@ protected Optional filterDataMappingSmokeTestData(DataMapp return Optional.empty(); case "time": + case "time(6)": case "timestamp": + case "timestamp(6)": case "timestamp(3) with time zone": + case "timestamp(6) with time zone": return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeMinioConnectorTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeMinioConnectorTest.java index 48fad77d4110..dd419ffcd7ff 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeMinioConnectorTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeMinioConnectorTest.java @@ -175,7 +175,12 @@ protected Optional filterCaseSensitiveDataMappingTestData( protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) { String typeName = dataMappingTestSetup.getTrinoTypeName(); - if (typeName.equals("time") || typeName.equals("timestamp") || typeName.equals("char(3)")) { + if (typeName.equals("time") || + typeName.equals("time(6)") || + typeName.equals("timestamp") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(6) with time zone") || + typeName.equals("char(3)")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } return Optional.of(dataMappingTestSetup); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index cf4c0566077d..7f6ffa9640bf 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -8634,9 +8634,15 @@ protected Optional filterDataMappingSmokeTestData(DataMapp { String typeName = dataMappingTestSetup.getTrinoTypeName(); if (typeName.equals("time") - || typeName.equals("timestamp(3) with time zone")) { + || typeName.equals("time(6)") + || typeName.equals("timestamp(3) with time zone") + || typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } + if (typeName.equals("timestamp(6)")) { + // It's supported depending on hive timestamp precision configuration, so the exception message doesn't match the expected for asUnsupported(). + return Optional.empty(); + } return Optional.of(dataMappingTestSetup); } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java index fffad0085648..f35415961f59 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java @@ -2854,16 +2854,10 @@ protected Optional filterDataMappingSmokeTestData(DataMapp } // According to Iceberg specification all time and timestamp values are stored with microsecond precision. - if (typeName.equals("time")) { - return Optional.of(new DataMappingTestSetup("time(6)", "TIME '15:03:00'", "TIME '23:59:59.999999'")); - } - - if (typeName.equals("timestamp")) { - return Optional.of(new DataMappingTestSetup("timestamp(6)", "TIMESTAMP '2020-02-12 15:03:00'", "TIMESTAMP '2199-12-31 23:59:59.999999'")); - } - - if (typeName.equals("timestamp(3) with time zone")) { - return Optional.of(new DataMappingTestSetup("timestamp(6) with time zone", "TIMESTAMP '2020-02-12 15:03:00 +01:00'", "TIMESTAMP '9999-12-31 23:59:59.999999 +12:00'")); + if (typeName.equals("time") || + typeName.equals("timestamp") || + typeName.equals("timestamp(3) with time zone")) { + return Optional.of(dataMappingTestSetup.asUnsupported()); } return Optional.of(dataMappingTestSetup); diff --git a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java index defd869c8cda..be38c0b2f30c 100644 --- a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java +++ b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java @@ -457,7 +457,10 @@ protected Optional filterDataMappingSmokeTestData(DataMapp { String typeName = dataMappingTestSetup.getTrinoTypeName(); if (typeName.equals("time") - || typeName.equals("timestamp(3) with time zone")) { + || typeName.equals("time(6)") + || typeName.equals("timestamp(6)") + || typeName.equals("timestamp(3) with time zone") + || typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java index 5e128fb478e0..c320a6a88709 100644 --- a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java +++ b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java @@ -114,8 +114,10 @@ protected boolean isColumnNameRejected(Exception exception, String columnName, b protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) { String typeName = dataMappingTestSetup.getTrinoTypeName(); - if (typeName.equals("timestamp(3) with time zone") - || typeName.equals("timestamp")) { + if (typeName.equals("timestamp") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java index 2a71ee5583d9..becf0cb3e60d 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java @@ -36,6 +36,7 @@ import java.time.LocalDateTime; import java.util.Arrays; import java.util.Date; +import java.util.Optional; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; @@ -102,6 +103,18 @@ public void testSortItemsReflectedInExplain() "TopNPartial\\[5 by \\(nationkey DESC"); } + @Override + protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) + { + String typeName = dataMappingTestSetup.getTrinoTypeName(); + if (typeName.equals("time(6)") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(6) with time zone")) { + return Optional.of(dataMappingTestSetup.asUnsupported()); + } + return Optional.of(dataMappingTestSetup); + } + @Test(dataProvider = "guessFieldTypesProvider") public void testGuessFieldTypes(String mongoValue, String trinoValue) { diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java index 4e8cf3945f63..522ad15a3734 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java @@ -134,7 +134,8 @@ protected boolean isColumnNameRejected(Exception exception, String columnName, b protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) { String typeName = dataMappingTestSetup.getTrinoTypeName(); - if (typeName.equals("timestamp(3) with time zone")) { + if (typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java index 733b6b81145c..1f158ce3c7ec 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java @@ -104,8 +104,11 @@ protected Optional filterDataMappingSmokeTestData(DataMapp return Optional.empty(); } } - if (typeName.equals("time")) { - return Optional.empty(); + if (typeName.equals("time") || + typeName.equals("time(6)") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(6) with time zone")) { + return Optional.of(dataMappingTestSetup.asUnsupported()); } if (typeName.equals("boolean")) { // Oracle does not have native support for boolean however usually it is represented as number(1) diff --git a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java index 2fdf20e3b73b..c2ff6fa99154 100644 --- a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java @@ -182,8 +182,11 @@ protected boolean isColumnNameRejected(Exception exception, String columnName, b protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) { String typeName = dataMappingTestSetup.getTrinoTypeName(); - if (typeName.equals("timestamp") - || typeName.equals("timestamp(3) with time zone")) { + if (typeName.equals("time(6)") || + typeName.equals("timestamp") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java index acf256c4c979..9aca02743a9b 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java @@ -200,8 +200,11 @@ protected boolean isColumnNameRejected(Exception exception, String columnName, b protected Optional filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup) { String typeName = dataMappingTestSetup.getTrinoTypeName(); - if (typeName.equals("timestamp") - || typeName.equals("timestamp(3) with time zone")) { + if (typeName.equals("time(6)") || + typeName.equals("timestamp") || + typeName.equals("timestamp(6)") || + typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java index b1356409f7f0..639fd6902651 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java @@ -134,7 +134,10 @@ protected Optional filterDataMappingSmokeTestData(DataMapp || typeName.equals("real") || typeName.startsWith("decimal(") || typeName.equals("time") + || typeName.equals("time(6)") + || typeName.equals("timestamp(6)") || typeName.equals("timestamp(3) with time zone") + || typeName.equals("timestamp(6) with time zone") || typeName.startsWith("char(")) { //TODO this should either work or fail cleanly return Optional.empty(); diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java index 14279cfc97a4..37ec38062152 100644 --- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java +++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java @@ -137,7 +137,8 @@ protected Optional filterDataMappingSmokeTestData(DataMapp return Optional.empty(); } - if (typeName.equals("timestamp(3) with time zone")) { + if (typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java index 7c8dae460edb..66e8773f6956 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java @@ -131,7 +131,8 @@ protected Optional filterDataMappingSmokeTestData(DataMapp return Optional.empty(); } } - if (typeName.equals("timestamp(3) with time zone")) { + if (typeName.equals("timestamp(3) with time zone") || + typeName.equals("timestamp(6) with time zone")) { return Optional.of(dataMappingTestSetup.asUnsupported()); } diff --git a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java index 94a7def8999c..11bc246b4a2d 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java @@ -3335,8 +3335,11 @@ private List testDataMappingSmokeTestData() .add(new DataMappingTestSetup("date", "DATE '1582-10-05'", "DATE '1582-10-14'")) // during julian->gregorian switch .add(new DataMappingTestSetup("date", "DATE '2020-02-12'", "DATE '9999-12-31'")) .add(new DataMappingTestSetup("time", "TIME '15:03:00'", "TIME '23:59:59.999'")) + .add(new DataMappingTestSetup("time(6)", "TIME '15:03:00'", "TIME '23:59:59.999999'")) .add(new DataMappingTestSetup("timestamp", "TIMESTAMP '2020-02-12 15:03:00'", "TIMESTAMP '2199-12-31 23:59:59.999'")) + .add(new DataMappingTestSetup("timestamp(6)", "TIMESTAMP '2020-02-12 15:03:00'", "TIMESTAMP '2199-12-31 23:59:59.999999'")) .add(new DataMappingTestSetup("timestamp(3) with time zone", "TIMESTAMP '2020-02-12 15:03:00 +01:00'", "TIMESTAMP '9999-12-31 23:59:59.999 +12:00'")) + .add(new DataMappingTestSetup("timestamp(6) with time zone", "TIMESTAMP '2020-02-12 15:03:00 +01:00'", "TIMESTAMP '9999-12-31 23:59:59.999999 +12:00'")) .add(new DataMappingTestSetup("char(3)", "'ab'", "'zzz'")) .add(new DataMappingTestSetup("varchar(3)", "'de'", "'zzz'")) .add(new DataMappingTestSetup("varchar", "'łąka for the win'", "'ŻŻŻŻŻŻŻŻŻŻ'")) From 42c4a8bdfef4bb6b32bab5a1b9c28804540b9710 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Mon, 30 May 2022 15:31:26 +0200 Subject: [PATCH 2/3] empty From d713008fc3b5e28c6a5c8f8c8c2e4dcea4ce9bd7 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 1 Jun 2022 07:49:15 +0200 Subject: [PATCH 3/3] empty