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/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; } 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/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 404b790e40f1..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 @@ -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,10 +27,10 @@ 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") + .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 117831a3719d..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 @@ -29,18 +29,24 @@ 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"); + + // 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() { - 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);