From a08ee8e779880b72bbfb6f528c98eccc7f65dc86 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 18 Jan 2022 21:08:45 +0900 Subject: [PATCH 1/4] Create TPCH schema on Trino in ClickHouse query runner --- .../java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java index 9e178772d902..5338679e0414 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java @@ -65,7 +65,7 @@ public static DistributedQueryRunner createClickHouseQueryRunner( queryRunner.installPlugin(new ClickHousePlugin()); queryRunner.createCatalog("clickhouse", "clickhouse", connectorProperties); - server.execute("CREATE DATABASE " + TPCH_SCHEMA); + queryRunner.execute("CREATE SCHEMA " + TPCH_SCHEMA); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); return queryRunner; } From acc32ecb5de4343cf959360cb17e4913123ccbd0 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 18 Jan 2022 21:15:43 +0900 Subject: [PATCH 2/4] Change constructor argument of TestingClickHouseServer --- .../TestClickHouseLatestConnectorSmokeTest.java | 4 ++-- .../plugin/clickhouse/TestingClickHouseServer.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java index 404b790e40f1..60928b066746 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java @@ -17,7 +17,7 @@ import io.trino.testing.QueryRunner; import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; -import static io.trino.plugin.clickhouse.TestingClickHouseServer.LATEST_VERSION; +import static io.trino.plugin.clickhouse.TestingClickHouseServer.CLICKHOUSE_LATEST_IMAGE; public class TestClickHouseLatestConnectorSmokeTest extends BaseClickHouseConnectorSmokeTest @@ -27,7 +27,7 @@ protected QueryRunner createQueryRunner() throws Exception { return createClickHouseQueryRunner( - closeAfterClass(new TestingClickHouseServer(LATEST_VERSION)), + closeAfterClass(new TestingClickHouseServer(CLICKHOUSE_LATEST_IMAGE)), ImmutableMap.of(), ImmutableMap.builder() .put("clickhouse.map-string-as-varchar", "true") 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 117831a3719d..1c77688e47ae 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 @@ -29,18 +29,18 @@ public class TestingClickHouseServer implements Closeable { private static final DockerImageName CLICKHOUSE_IMAGE = DockerImageName.parse("yandex/clickhouse-server"); - public static final String LATEST_VERSION = "21.11.10.1"; - public static final String DEFAULT_VERSION = "20.8"; + public static final DockerImageName CLICKHOUSE_LATEST_IMAGE = CLICKHOUSE_IMAGE.withTag("21.11.10.1"); + public static final DockerImageName CLICKHOUSE_DEFAULT_IMAGE = CLICKHOUSE_IMAGE.withTag("20.8"); private final ClickHouseContainer dockerContainer; public TestingClickHouseServer() { - this(DEFAULT_VERSION); + this(CLICKHOUSE_DEFAULT_IMAGE); } - public TestingClickHouseServer(String version) + public TestingClickHouseServer(DockerImageName image) { - dockerContainer = (ClickHouseContainer) new ClickHouseContainer(CLICKHOUSE_IMAGE.withTag(version)) + dockerContainer = (ClickHouseContainer) new ClickHouseContainer(image) .withCopyFileToContainer(forClasspathResource("custom.xml"), "/etc/clickhouse-server/config.d/custom.xml") .withStartupAttempts(10); From b630d5b93a57c1f319239564eba3995441ab9e66 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Wed, 19 Jan 2022 21:02:13 +0900 Subject: [PATCH 3/4] Add comment for clickhouse.map-string-as-varchar in ClickHouse tests --- .../plugin/clickhouse/TestClickHouseConnectorSmokeTest.java | 2 +- .../clickhouse/TestClickHouseLatestConnectorSmokeTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java index a8bdbafc11b0..c9dd65178074 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java @@ -34,7 +34,7 @@ protected QueryRunner createQueryRunner() clickHouseServer, ImmutableMap.of(), ImmutableMap.builder() - .put("clickhouse.map-string-as-varchar", "true") + .put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary .buildOrThrow(), REQUIRED_TPCH_TABLES); } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java index 60928b066746..a2b7892ea261 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java @@ -30,7 +30,7 @@ protected QueryRunner createQueryRunner() closeAfterClass(new TestingClickHouseServer(CLICKHOUSE_LATEST_IMAGE)), ImmutableMap.of(), ImmutableMap.builder() - .put("clickhouse.map-string-as-varchar", "true") + .put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary .buildOrThrow(), REQUIRED_TPCH_TABLES); } From 5c07a266844966afbd08630eb38f3d8d583bfe73 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 18 Jan 2022 21:17:46 +0900 Subject: [PATCH 4/4] Add ClickHouse smoke tests for Altinity --- docs/src/main/sphinx/connector/clickhouse.rst | 2 +- .../TestAltinityConnectorSmokeTest.java | 46 +++++++++++++++++++ .../TestAltinityLatestConnectorSmokeTest.java | 37 +++++++++++++++ .../clickhouse/TestingClickHouseServer.java | 6 +++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityConnectorSmokeTest.java create mode 100644 plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityLatestConnectorSmokeTest.java diff --git a/docs/src/main/sphinx/connector/clickhouse.rst b/docs/src/main/sphinx/connector/clickhouse.rst index 05e17193aaec..8fd9e1dbc6fe 100644 --- a/docs/src/main/sphinx/connector/clickhouse.rst +++ b/docs/src/main/sphinx/connector/clickhouse.rst @@ -12,7 +12,7 @@ Requirements To connect to a ClickHouse server, you need: -* ClickHouse version 20.8 or higher. +* ClickHouse (version 20.8 or higher) or Altinity (version 20.3 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/TestAltinityConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityConnectorSmokeTest.java new file mode 100644 index 000000000000..ab9356545922 --- /dev/null +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityConnectorSmokeTest.java @@ -0,0 +1,46 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.trino.plugin.clickhouse; + +import com.google.common.collect.ImmutableMap; +import io.trino.testing.QueryRunner; + +import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; +import static io.trino.plugin.clickhouse.TestingClickHouseServer.ALTINITY_DEFAULT_IMAGE; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class TestAltinityConnectorSmokeTest + extends BaseClickHouseConnectorSmokeTest +{ + @Override + protected QueryRunner createQueryRunner() + throws Exception + { + return createClickHouseQueryRunner( + closeAfterClass(new TestingClickHouseServer(ALTINITY_DEFAULT_IMAGE)), + ImmutableMap.of(), + ImmutableMap.builder() + .put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary + .buildOrThrow(), + REQUIRED_TPCH_TABLES); + } + + @Override + public void testRenameSchema() + { + // Override because RENAME DATABASE statement isn't supported in version < v20.7.2.30-stable + assertThatThrownBy(super::testRenameSchema) + .hasMessageMatching("ClickHouse exception, code: 62,.* Syntax error.*\\n"); + } +} diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityLatestConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityLatestConnectorSmokeTest.java new file mode 100644 index 000000000000..0820e4d58819 --- /dev/null +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestAltinityLatestConnectorSmokeTest.java @@ -0,0 +1,37 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.trino.plugin.clickhouse; + +import com.google.common.collect.ImmutableMap; +import io.trino.testing.QueryRunner; + +import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner; +import static io.trino.plugin.clickhouse.TestingClickHouseServer.ALTINITY_LATEST_IMAGE; + +public class TestAltinityLatestConnectorSmokeTest + extends BaseClickHouseConnectorSmokeTest +{ + @Override + protected QueryRunner createQueryRunner() + throws Exception + { + return createClickHouseQueryRunner( + closeAfterClass(new TestingClickHouseServer(ALTINITY_LATEST_IMAGE)), + ImmutableMap.of(), + ImmutableMap.builder() + .put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary + .buildOrThrow(), + REQUIRED_TPCH_TABLES); + } +} 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 1c77688e47ae..9e99edeb3234 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,6 +31,12 @@ 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("20.8"); + + // Altinity Stable Builds Life-Cycle Table https://docs.altinity.com/altinitystablebuilds/#altinity-stable-builds-life-cycle-table + private static final DockerImageName ALTINITY_IMAGE = DockerImageName.parse("altinity/clickhouse-server").asCompatibleSubstituteFor("yandex/clickhouse-server"); + public static final DockerImageName ALTINITY_LATEST_IMAGE = ALTINITY_IMAGE.withTag("21.8.13.1.altinitystable"); + public static final DockerImageName ALTINITY_DEFAULT_IMAGE = ALTINITY_IMAGE.withTag("20.3.12-aes"); // EOL is 24 June 2022 + private final ClickHouseContainer dockerContainer; public TestingClickHouseServer()