diff --git a/docs/src/main/sphinx/connector/clickhouse.rst b/docs/src/main/sphinx/connector/clickhouse.rst index 77a045204ab9..8914df2d9c73 100644 --- a/docs/src/main/sphinx/connector/clickhouse.rst +++ b/docs/src/main/sphinx/connector/clickhouse.rst @@ -16,7 +16,7 @@ Requirements To connect to a ClickHouse server, you need: -* ClickHouse (version 21.3 or higher) or Altinity (version 20.8 or higher). +* ClickHouse (version 21.8 or higher) or Altinity (version 20.8 or higher). * Network access from the Trino coordinator and workers to the ClickHouse server. Port 8123 is the default port. 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 8743919c371b..d90581f1499b 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 @@ -634,13 +634,13 @@ public void testInsertIntoNotNullColumn() @Override protected String errorMessageForCreateTableAsSelectNegativeDate(String date) { - return "Date must be between 1970-01-01 and 2106-02-07 in ClickHouse: " + date; + return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; } @Override protected String errorMessageForInsertNegativeDate(String date) { - return "Date must be between 1970-01-01 and 2106-02-07 in ClickHouse: " + date; + return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; } @Test @@ -656,7 +656,7 @@ public void testDateYearOfEraPredicate() protected String errorMessageForDateYearOfEraPredicate(String date) { - return "Date must be between 1970-01-01 and 2106-02-07 in ClickHouse: " + date; + return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; } @Override @@ -845,6 +845,13 @@ public void testRenameTableToLongTableName() assertFalse(getQueryRunner().tableExists(getSession(), invalidTargetTableName)); } + @Override + protected OptionalInt maxTableNameLength() + { + // The numeric value depends on file system + return OptionalInt.of(255 - ".sql.detached".length()); + } + @Override protected SqlExecutor onRemoteDatabase() { diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java index 3e39c763769f..9e89969fc285 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java @@ -648,7 +648,7 @@ public Object[][] clickHouseDateMinMaxValuesDataProvider() { return new Object[][] { {"1970-01-01"}, // min value in ClickHouse - {"2106-02-07"}, // max value in ClickHouse + {"2149-06-06"}, // max value in ClickHouse }; } @@ -675,7 +675,7 @@ public Object[][] unsupportedClickHouseDateValuesDataProvider() { return new Object[][] { {"1969-12-31"}, // min - 1 day - {"2106-02-08"}, // max + 1 day + {"2149-06-07"}, // max + 1 day }; } @@ -715,7 +715,7 @@ private SqlDataTypeTest timestampTest(String inputType) protected SqlDataTypeTest unsupportedTimestampBecomeUnexpectedValueTest(String inputType) { return SqlDataTypeTest.create() - .addRoundTrip(inputType, "'1969-12-31 23:59:59'", createTimestampType(0), "TIMESTAMP '1970-01-01 23:59:59'"); // unsupported timestamp become 1970-01-01 23:59:59 + .addRoundTrip(inputType, "'1969-12-31 23:59:59'", createTimestampType(0), "TIMESTAMP '1970-01-01 00:00:00'"); } @Test(dataProvider = "clickHouseDateTimeMinMaxValuesDataProvider") @@ -747,7 +747,7 @@ public Object[][] clickHouseDateTimeMinMaxValuesDataProvider() { return new Object[][] { {"1970-01-01 00:00:00"}, // min value in ClickHouse - {"2106-02-06 06:28:15"}, // max value in ClickHouse + {"2106-02-07 06:28:15"}, // max value in ClickHouse }; } @@ -774,7 +774,7 @@ public Object[][] unsupportedTimestampDataProvider() { return new Object[][] { {"1969-12-31 23:59:59"}, // min - 1 second - {"2106-02-06 06:28:16"}, // max + 1 second + {"2106-02-07 06:28:16"}, // max + 1 second }; } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java index 1c8aeba5dfca..49335e8d849a 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java @@ -16,8 +16,6 @@ import com.google.common.collect.ImmutableMap; import io.trino.testing.QueryRunner; -import java.util.OptionalInt; - import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -45,38 +43,6 @@ public void testCommentTable() .hasMessageContaining("Code: 62, e.displayText() = DB::Exception: Syntax error"); } - @Override - public void testCreateTableWithTableComment() - { - // Table comment is unsupported in old ClickHouse version - assertThatThrownBy(super::testCreateTableWithTableComment) - .hasMessageMatching("(?s).* Syntax error: .* COMMENT 'test comment'.*"); - } - - @Override - public void testCreateTableAsSelectWithTableComment() - { - // Table comment is unsupported in old ClickHouse version - assertThatThrownBy(super::testCreateTableAsSelectWithTableComment) - .hasMessageMatching("(?s).* Syntax error: .* COMMENT 'test comment'.*"); - } - - @Override - public void testCreateTableWithTableCommentSpecialCharacter(String comment) - { - // Table comment is unsupported in old ClickHouse version - assertThatThrownBy(() -> super.testCreateTableWithTableCommentSpecialCharacter(comment)) - .hasMessageMatching("(?s).* Syntax error: .* COMMENT .*"); - } - - @Override - public void testCreateTableAsSelectWithTableCommentSpecialCharacter(String comment) - { - // Table comment is unsupported in old ClickHouse version - assertThatThrownBy(() -> super.testCreateTableAsSelectWithTableCommentSpecialCharacter(comment)) - .hasMessageMatching("(?s).* Syntax error: .* COMMENT .*"); - } - @Override public void testCommentTableSpecialCharacter(String comment) { @@ -84,11 +50,4 @@ public void testCommentTableSpecialCharacter(String comment) assertThatThrownBy(() -> super.testCommentTableSpecialCharacter(comment)) .hasMessageMatching("(?s).* Syntax error: .* COMMENT .*"); } - - @Override - protected OptionalInt maxTableNameLength() - { - // The numeric value depends on file system - return OptionalInt.of(255 - ".sql.tmp".length()); - } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorTest.java index 47b0e22ff467..c1b82099e010 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorTest.java @@ -16,8 +16,6 @@ import com.google.common.collect.ImmutableMap; import io.trino.testing.QueryRunner; -import java.util.OptionalInt; - import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; import static io.trino.plugin.clickhouse.TestingClickHouseServer.CLICKHOUSE_LATEST_IMAGE; @@ -37,32 +35,4 @@ protected QueryRunner createQueryRunner() .buildOrThrow(), REQUIRED_TPCH_TABLES); } - - @Override - protected OptionalInt maxTableNameLength() - { - // The numeric value depends on file system - return OptionalInt.of(255 - ".sql.detached".length()); - } - - @Override - protected String errorMessageForCreateTableAsSelectNegativeDate(String date) - { - // Override because the DateTime range was expanded in version 21.4 and later - return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; - } - - @Override - protected String errorMessageForInsertNegativeDate(String date) - { - // Override because the DateTime range was expanded in version 21.4 and later - return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; - } - - @Override - protected String errorMessageForDateYearOfEraPredicate(String date) - { - // Override because the DateTime range was expanded in version 21.4 and later - return "Date must be between 1970-01-01 and 2149-06-06 in ClickHouse: " + date; - } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestTypeMapping.java index 5208050caaba..80556e674c53 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestTypeMapping.java @@ -13,15 +13,10 @@ */ package io.trino.plugin.clickhouse; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import io.trino.testing.QueryRunner; -import io.trino.testing.datatype.SqlDataTypeTest; -import org.testng.annotations.DataProvider; import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; import static io.trino.plugin.clickhouse.TestingClickHouseServer.CLICKHOUSE_LATEST_IMAGE; -import static io.trino.spi.type.TimestampType.createTimestampType; public class TestClickHouseLatestTypeMapping extends BaseClickHouseTypeMapping @@ -31,65 +26,6 @@ protected QueryRunner createQueryRunner() throws Exception { clickhouseServer = closeAfterClass(new TestingClickHouseServer(CLICKHOUSE_LATEST_IMAGE)); - return createClickHouseQueryRunner(clickhouseServer, ImmutableMap.of(), - ImmutableMap.builder() - .put("metadata.cache-ttl", "10m") - .put("metadata.cache-missing", "true") - .buildOrThrow(), - ImmutableList.of()); - } - - @DataProvider - @Override - public Object[][] clickHouseDateMinMaxValuesDataProvider() - { - // Override because the Date range was expanded in version 21.4 and later - return new Object[][] { - {"1970-01-01"}, // min value in ClickHouse - {"2149-06-06"}, // max value in ClickHouse - }; - } - - @DataProvider - @Override - public Object[][] unsupportedClickHouseDateValuesDataProvider() - { - // Override because the Date range was expanded in version 21.4 and later - return new Object[][] { - {"1969-12-31"}, // min - 1 day - {"2149-06-07"}, // max + 1 day - }; - } - - @Override - protected SqlDataTypeTest unsupportedTimestampBecomeUnexpectedValueTest(String inputType) - { - // Override because insert DateTime '1969-12-31 23:59:59' directly in ClickHouse will - // become '1970-01-01 00:00:00' in version 21.4 and later, however in versions prior - // to 21.4 the value will become '1970-01-01 23:59:59'. - return SqlDataTypeTest.create() - .addRoundTrip(inputType, "'1969-12-31 23:59:59'", createTimestampType(0), "TIMESTAMP '1970-01-01 00:00:00'"); - } - - @DataProvider - @Override - public Object[][] clickHouseDateTimeMinMaxValuesDataProvider() - { - // Override because the DateTime range was expanded in version 21.4 and later - return new Object[][] { - {"1970-01-01 00:00:00"}, // min value in ClickHouse - {"2106-02-07 06:28:15"}, // max value in ClickHouse - }; - } - - @DataProvider - @Override - public Object[][] unsupportedTimestampDataProvider() - { - // Override because the DateTime range was expanded in version 21.4 and later - return new Object[][] { - {"1969-12-31 23:59:59"}, // min - 1 second - {"2106-02-07 06:28:16"}, // max + 1 second - }; + return createClickHouseQueryRunner(clickhouseServer); } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java index eaf4161bfe92..3e42c49edb0d 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java @@ -13,8 +13,6 @@ */ package io.trino.plugin.clickhouse; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import io.trino.testing.QueryRunner; import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; @@ -27,11 +25,6 @@ protected QueryRunner createQueryRunner() throws Exception { clickhouseServer = closeAfterClass(new TestingClickHouseServer()); - return createClickHouseQueryRunner(clickhouseServer, ImmutableMap.of(), - ImmutableMap.builder() - .put("metadata.cache-ttl", "10m") - .put("metadata.cache-missing", "true") - .buildOrThrow(), - ImmutableList.of()); + return createClickHouseQueryRunner(clickhouseServer); } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java index 7aac0e1c4531..55bcf7cc5204 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java @@ -31,7 +31,7 @@ public class TestingClickHouseServer { private static final DockerImageName CLICKHOUSE_IMAGE = DockerImageName.parse("yandex/clickhouse-server"); public static final DockerImageName CLICKHOUSE_LATEST_IMAGE = CLICKHOUSE_IMAGE.withTag("21.11.10.1"); - public static final DockerImageName CLICKHOUSE_DEFAULT_IMAGE = CLICKHOUSE_IMAGE.withTag("21.3.2.5"); // EOL is 30 Mar 2022 + public static final DockerImageName CLICKHOUSE_DEFAULT_IMAGE = CLICKHOUSE_IMAGE.withTag("21.8.14.5"); // EOL is 31 Aug 2022 private static final String CLICKHOUSE_LATEST_DRIVER_CLASS_NAME = "com.clickhouse.jdbc.ClickHouseDriver"; // TODO: This Driver will not be available when clickhouse-jdbc is upgraded to 0.4.0 or above