diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
index 2b49220965ffde..86607d1f83a372 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
@@ -258,6 +258,36 @@ Caused by: java.io.UnsupportedEncodingException: Codepage Cp1252 is not supporte
```
+6. 当需要通过 ShardingSphere JDBC 使用 ClickHouse 方言时,
+用户需要手动引入相关的可选模块和 classifier 为 `http` 的 ClickHouse JDBC 驱动。
+原则上,ShardingSphere 的 GraalVM Native Image 集成不希望使用 classifier 为 `all` 的 `com.clickhouse:clickhouse-jdbc`,
+因为 Uber Jar 会导致采集重复的 GraalVM Reachability Metadata。
+可能的配置例子如下,
+```xml
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-jdbc
+ ${shardingsphere.version}
+
+
+ org.apache.shardingsphere
+ shardingsphere-parser-sql-clickhouse
+ ${shardingsphere.version}
+
+
+ com.clickhouse
+ clickhouse-jdbc
+ 0.6.0-patch5
+ http
+
+
+
+```
+
+ClickHouse 不支持 ShardingSphere 集成级别的本地事务,XA 事务和 Seata AT 模式事务,更多讨论位于 https://github.com/ClickHouse/clickhouse-docs/issues/2300 。
+
## 贡献 GraalVM Reachability Metadata
ShardingSphere 对在 GraalVM Native Image 下的可用性的验证,是通过 GraalVM Native Build Tools 的 Maven Plugin 子项目来完成的。
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
index 1c3b1ec26480b4..9dc087c94a7487 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
@@ -269,6 +269,36 @@ Possible configuration examples are as follows,
```
+6. When using the ClickHouse dialect through ShardingSphere JDBC,
+users need to manually introduce the relevant optional modules and the ClickHouse JDBC driver with the classifier `http`.
+In principle, ShardingSphere's GraalVM Native Image integration does not want to use `com.clickhouse:clickhouse-jdbc` with classifier `all`,
+because Uber Jar will cause the collection of duplicate GraalVM Reachability Metadata.
+Possible configuration examples are as follows,
+```xml
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-jdbc
+ ${shardingsphere.version}
+
+
+ org.apache.shardingsphere
+ shardingsphere-parser-sql-clickhouse
+ ${shardingsphere.version}
+
+
+ com.clickhouse
+ clickhouse-jdbc
+ 0.6.0-patch5
+ http
+
+
+
+```
+ClickHouse does not support local transactions, XA transactions, and Seata AT mode transactions at the ShardingSphere integration level.
+More discussion is at https://github.com/ClickHouse/clickhouse-docs/issues/2300 .
+
## Contribute GraalVM Reachability Metadata
The verification of ShardingSphere's availability under GraalVM Native Image is completed through the Maven Plugin subproject
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.cn.md
index 257dff134cca25..dc240b7613debe 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.cn.md
@@ -30,7 +30,6 @@ ShardingSphere 默认情况下仅包含核心 SPI 的实现,在 Git Source 存
- `org.apache.shardingsphere:shardingsphere-sql-parser-opengauss`, SQL 解析的 OpenGauss 方言实现
- `org.apache.shardingsphere:shardingsphere-sql-parser-oracle`, SQL 解析的 Oracle 方言解析实现
- `org.apache.shardingsphere:shardingsphere-sql-parser-sqlserver`, SQL 解析的 SQL Server 方言实现
-- `org.apache.shardingsphere:shardingsphere-sql-parser-clickhouse`, SQL 解析的 ClickHouse 方言实现
- `org.apache.shardingsphere:shardingsphere-sql-parser-doris`, SQL 解析的 Doris 方言实现
- `org.apache.shardingsphere:shardingsphere-sql-parser-hive`, SQL 解析的 Hive 方言实现
- `org.apache.shardingsphere:shardingsphere-sql-parser-presto`, SQL 解析的 Presto 方言实现
@@ -44,8 +43,6 @@ ShardingSphere 默认情况下仅包含核心 SPI 的实现,在 Git Source 存
下以 `groupId:artifactId` 的表现形式列出所有的可选插件。
-- 单机模式配置信息持久化定义
- - `org.apache.shardingsphere:shardingsphere-standalone-mode-repository-jdbc-mysql`,基于 MySQL 的持久化
- 集群模式配置信息持久化定义
- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-zookeeper`,基于 Zookeeper 的持久化实现
- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-etcd`,基于 Etcd 的持久化实现
@@ -55,5 +52,7 @@ ShardingSphere 默认情况下仅包含核心 SPI 的实现,在 Git Source 存
- `org.apache.shardingsphere:shardingsphere-infra-expr-espresso`,基于 GraalVM Truffle 的 Espresso 实现的使用 Groovy 语法的行表达式
- 数据库类型识别
- `org.apache.shardingsphere:shardingsphere-infra-database-testcontainers`, 对 `testcontainers-java` 的 `JDBC support` 的 jdbcURL 的识别适配
+- SQL 解析
+ - `org.apache.shardingsphere:shardingsphere-sql-parser-clickhouse`, SQL 解析的 ClickHouse 方言实现
除了以上可选插件外,ShardingSphere 社区开发者还贡献了大量的插件实现,可以在 [ShardingSphere Plugin](https://github.com/apache/shardingsphere-plugin) 仓库中查看插件的使用说明,ShardingSphere Plugin 仓库中的插件会和 ShardingSphere 保持相同的发布节奏,可以在 https://central.sonatype.com/ 进行检索,并安装到 ShardingSphere 中。
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.en.md
index 83887b436e3826..c54e2b74889d2d 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/_index.en.md
@@ -30,7 +30,6 @@ All the built-in plugins for ShardingSphere-JDBC are listed below in the form of
- `org.apache.shardingsphere:shardingsphere-sql-parser-opengauss`, OpenGauss dialect implementation of SQL parsing
- `org.apache.shardingsphere:shardingsphere-sql-parser-oracle`, Oracle dialect implementation of SQL parsing
- `org.apache.shardingsphere:shardingsphere-sql-parser-sqlserver`, SQL Server dialect implementation of SQL parsing
-- `org.apache.shardingsphere:shardingsphere-sql-parser-clickhouse`, ClickHouse dialect implementation of SQL parsing
- `org.apache.shardingsphere:shardingsphere-sql-parser-doris`, Doris dialect implementation of SQL parsing
- `org.apache.shardingsphere:shardingsphere-sql-parser-hive`, Hive dialect implementation of SQL parsing
- `org.apache.shardingsphere:shardingsphere-sql-parser-presto`, Presto dialect implementation of SQL parsing
@@ -44,8 +43,6 @@ If ShardingSphere-JDBC needs to use optional plugins, you need to download the J
All optional plugins are listed below in the form of `groupId:artifactId`.
-- Standalone mode configuration information persistence definition
- - `org.apache.shardingsphere:shardingsphere-standalone-mode-repository-jdbc-mysql`, MySQL based persistence
- Cluster mode configuration information persistence definition
- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-zookeeper`, Zookeeper based persistence
- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-etcd`, Etcd based persistence
@@ -55,5 +52,7 @@ All optional plugins are listed below in the form of `groupId:artifactId`.
- `org.apache.shardingsphere:shardingsphere-infra-expr-espresso`,Row Value Expressions that uses the Groovy syntax based on GraalVM Truffle's Espresso implementation
- Database type identification
- `org.apache.shardingsphere:shardingsphere-infra-database-testcontainers`, Adaptation of jdbcURL for `JDBC support` of `testcontainers-java`
+- SQL parsing
+ - `org.apache.shardingsphere:shardingsphere-sql-parser-clickhouse`, ClickHouse dialect implementation of SQL parsing
In addition to the above optional plugins, ShardingSphere community developers have contributed a number of plugin implementations. These plugins can be found in [ShardingSphere Plugins] (https://github.com/apache/shardingsphere-plugin) repository. Plugins in ShardingSphere Plugin repository would remain the same release plan with ShardingSphere, they can be retrieved at https://central.sonatype.com/, and install into ShardingSphere.
diff --git a/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/connector/ClickHouseConnectionPropertiesParser.java b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/connector/ClickHouseConnectionPropertiesParser.java
new file mode 100644
index 00000000000000..07e6055cfcd97f
--- /dev/null
+++ b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/connector/ClickHouseConnectionPropertiesParser.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.infra.database.clickhouse.connector;
+
+import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties;
+import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser;
+import org.apache.shardingsphere.infra.database.core.connector.StandardConnectionProperties;
+import org.apache.shardingsphere.infra.database.core.connector.url.JdbcUrl;
+import org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser;
+
+import java.util.Properties;
+
+/**
+ * Connection properties parser of ClickHouse.
+ */
+public final class ClickHouseConnectionPropertiesParser implements ConnectionPropertiesParser {
+
+ private static final int DEFAULT_PORT = 8123;
+
+ @Override
+ public ConnectionProperties parse(final String url, final String username, final String catalog) {
+ JdbcUrl jdbcUrl = new StandardJdbcUrlParser().parse(url);
+ return new StandardConnectionProperties(jdbcUrl.getHostname(), jdbcUrl.getPort(DEFAULT_PORT), jdbcUrl.getDatabase(), null, jdbcUrl.getQueryProperties(), new Properties());
+ }
+
+ @Override
+ public String getDatabaseType() {
+ return "ClickHouse";
+ }
+}
diff --git a/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/metadata/database/ClickHouseDatabaseMetaData.java b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/metadata/database/ClickHouseDatabaseMetaData.java
new file mode 100644
index 00000000000000..3c2281d1124c9d
--- /dev/null
+++ b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/metadata/database/ClickHouseDatabaseMetaData.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.infra.database.clickhouse.metadata.database;
+
+import org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData;
+import org.apache.shardingsphere.infra.database.core.metadata.database.enums.NullsOrderType;
+import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter;
+
+/**
+ * Database meta data of ClickHouse.
+ */
+public final class ClickHouseDatabaseMetaData implements DialectDatabaseMetaData {
+
+ @Override
+ public QuoteCharacter getQuoteCharacter() {
+ return QuoteCharacter.QUOTE;
+ }
+
+ @Override
+ public NullsOrderType getDefaultNullsOrderType() {
+ return NullsOrderType.FIRST;
+ }
+
+ @Override
+ public String getDatabaseType() {
+ return "ClickHouse";
+ }
+}
diff --git a/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/type/ClickHouseDatabaseType.java b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/type/ClickHouseDatabaseType.java
index c03b7b18bb2dd1..53510ae33e87bc 100644
--- a/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/type/ClickHouseDatabaseType.java
+++ b/infra/database/type/clickhouse/src/main/java/org/apache/shardingsphere/infra/database/clickhouse/type/ClickHouseDatabaseType.java
@@ -18,15 +18,12 @@
package org.apache.shardingsphere.infra.database.clickhouse.type;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Optional;
/**
* Database type of ClickHouse.
- * ClickHouse currently uses MySQL dialect parsing.
*/
public final class ClickHouseDatabaseType implements DatabaseType {
@@ -35,11 +32,6 @@ public Collection getJdbcUrlPrefixes() {
return Arrays.asList("jdbc:ch:", "jdbc:clickhouse:");
}
- @Override
- public Optional getTrunkDatabaseType() {
- return Optional.of(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
- }
-
@Override
public String getType() {
return "ClickHouse";
diff --git a/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser b/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser
new file mode 100644
index 00000000000000..90df56bb2cebf6
--- /dev/null
+++ b/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.infra.database.clickhouse.connector.ClickHouseConnectionPropertiesParser
diff --git a/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData b/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData
new file mode 100644
index 00000000000000..4f96c02d334888
--- /dev/null
+++ b/infra/database/type/clickhouse/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.infra.database.clickhouse.metadata.database.ClickHouseDatabaseMetaData
diff --git a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
index 2e6c8735efb7e8..0f96b8da177064 100644
--- a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
+++ b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
@@ -20,8 +20,8 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Optional;
/**
@@ -29,9 +29,14 @@
*/
public final class TcClickHouseDatabaseType implements TestcontainersDatabaseType {
+ /**
+ * TODO See the JavaDoc for `org.apache.shardingsphere.test.natived.jdbc.commons.testcontainers.ClickHouseProvider`.
+ *
+ * @return prefixes of JDBC URL
+ */
@Override
public Collection getJdbcUrlPrefixes() {
- return Collections.singleton("jdbc:tc:clickhouse:");
+ return Arrays.asList("jdbc:tc:clickhouse:", "jdbc:tc:shardingsphere0clickhouse:");
}
@Override
diff --git a/infra/database/type/testcontainers/src/test/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseTypeTest.java b/infra/database/type/testcontainers/src/test/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseTypeTest.java
index 68e28adab730b0..4fb78478e27806 100644
--- a/infra/database/type/testcontainers/src/test/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseTypeTest.java
+++ b/infra/database/type/testcontainers/src/test/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseTypeTest.java
@@ -21,6 +21,7 @@
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.Test;
+import java.util.Arrays;
import java.util.Collections;
import static org.hamcrest.CoreMatchers.is;
@@ -30,7 +31,7 @@ class TestcontainersDatabaseTypeTest {
@Test
void assertGetJdbcUrlPrefixes() {
- assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-ClickHouse").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:clickhouse:")));
+ assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-ClickHouse").getJdbcUrlPrefixes(), is(Arrays.asList("jdbc:tc:clickhouse:", "jdbc:tc:shardingsphere0clickhouse:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-MariaDB").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:mariadb:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-MySQL").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:mysql:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-Oracle").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:oracle:")));
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json
index 49cc77934df2c5..50dce54f451eb4 100644
--- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json
@@ -3,18 +3,10 @@
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"},
"name":"[Lcom.fasterxml.jackson.databind.deser.BeanDeserializerModifier;"
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "name":"[Lcom.fasterxml.jackson.databind.deser.Deserializers;"
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"},
"name":"[Lcom.fasterxml.jackson.databind.ser.BeanSerializerModifier;"
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "name":"[Lcom.fasterxml.jackson.databind.ser.Serializers;"
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.datasource.pool.CatalogSwitchableDataSource"},
"name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;"
@@ -84,7 +76,7 @@
"name":"org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.rule.DatabaseRulePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseRulePersistService"},
"name":"org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration",
"allDeclaredFields":true
},
@@ -284,7 +276,7 @@
"methods":[{"name":"","parameterTypes":[] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }, {"name":"setType","parameterTypes":["java.lang.String"] }]
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.rule.DatabaseRulePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseRulePersistService"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProps","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
@@ -332,6 +324,14 @@
"name":"org.apache.shardingsphere.infra.algorithm.loadbalancer.weight.WeightLoadBalanceAlgorithm",
"methods":[{"name":"","parameterTypes":[] }]
},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolReflection"},
+ "name":"org.apache.shardingsphere.infra.database.clickhouse.connector.ClickHouseConnectionPropertiesParser"
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry"},
+ "name":"org.apache.shardingsphere.infra.database.clickhouse.metadata.database.ClickHouseDatabaseMetaData"
+},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.database.core.type.DatabaseTypeFactory"},
"name":"org.apache.shardingsphere.infra.database.clickhouse.type.ClickHouseDatabaseType"
@@ -528,26 +528,26 @@
"name":"org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaDataBuilder"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.ComputeNodePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService"},
"name":"org.apache.shardingsphere.infra.instance.yaml.YamlComputeNodeData",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"methods":[{"name":"","parameterTypes":[] }, {"name":"getAttribute","parameterTypes":[] }, {"name":"getVersion","parameterTypes":[] }, {"name":"setAttribute","parameterTypes":["java.lang.String"] }, {"name":"setVersion","parameterTypes":["java.lang.String"] }]
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.ComputeNodePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService"},
"name":"org.apache.shardingsphere.infra.instance.yaml.YamlComputeNodeDataBeanInfo"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.ComputeNodePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService"},
"name":"org.apache.shardingsphere.infra.instance.yaml.YamlComputeNodeDataCustomizer"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContexts"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory"},
"name":"org.apache.shardingsphere.infra.metadata.statistics.builder.dialect.MySQLShardingSphereStatisticsBuilder"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContexts"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory"},
"name":"org.apache.shardingsphere.infra.metadata.statistics.builder.dialect.PostgreSQLShardingSphereStatisticsBuilder"
},
{
@@ -572,7 +572,7 @@
"queryAllDeclaredMethods":true
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.subsciber.EventSubscriberRegistry$$Lambda/0x00007f12133825d0"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.subsciber.EventSubscriberRegistry$$Lambda/0x00007ffa03398208"},
"name":"org.apache.shardingsphere.infra.util.eventbus.EventSubscriber"
},
{
@@ -591,7 +591,7 @@
"queryAllPublicMethods":true
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.ComputeNodePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService"},
"name":"org.apache.shardingsphere.infra.util.yaml.YamlConfiguration",
"queryAllPublicMethods":true
},
@@ -896,20 +896,10 @@
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory"},
"name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.data.ShardingSphereDataChangedWatcher"
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder"},
- "name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.subscriber.ShardingSphereSchemaDataRegistrySubscriber",
- "queryAllDeclaredMethods":true
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory"},
"name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.watcher.MetaDataChangedWatcher"
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder"},
- "name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.subscriber.ClusterProcessSubscriber",
- "queryAllDeclaredMethods":true
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory"},
"name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.cluster.watcher.ClusterStateChangedWatcher"
@@ -940,19 +930,9 @@
"name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber.CacheEvictedSubscriber",
"methods":[{"name":"onGovernanceEvent","parameterTypes":["org.apache.shardingsphere.infra.rule.event.GovernanceEvent"] }]
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
- "name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber.ResourceMetaDataChangedSubscriber",
- "methods":[{"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.event.schema.table.CreateOrAlterTableEvent"] }, {"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.event.schema.table.DropTableEvent"] }]
-},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.infra.util.eventbus.EventBusContext"},
- "name":"org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber.StateChangedSubscriber",
- "methods":[{"name":"renew","parameterTypes":["org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.cluster.event.ClusterStateEvent"] }]
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.service.PersistServiceFacade"},
- "name":"org.apache.shardingsphere.mode.manager.cluster.service.ClusterMetaDataManagerPersistServiceBuilder",
+ "name":"org.apache.shardingsphere.mode.manager.cluster.service.ClusterPersistServiceBuilder",
"methods":[{"name":"","parameterTypes":[] }]
},
{
@@ -965,18 +945,13 @@
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.service.PersistServiceFacade"},
- "name":"org.apache.shardingsphere.mode.manager.standalone.service.StandaloneMetaDataManagerPersistServiceBuilder",
+ "name":"org.apache.shardingsphere.mode.manager.standalone.service.StandalonePersistServiceBuilder",
"methods":[{"name":"","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.yaml.config.swapper.mode.YamlModeConfigurationSwapper"},
"name":"org.apache.shardingsphere.mode.manager.standalone.yaml.StandaloneYamlPersistRepositoryConfigurationSwapper"
},
-{
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder"},
- "name":"org.apache.shardingsphere.mode.process.ProcessSubscriber",
- "queryAllDeclaredMethods":true
-},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder"},
"name":"org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository",
@@ -1398,7 +1373,7 @@
"name":"org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.rule.DatabaseRulePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseRulePersistService"},
"name":"org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration",
"allDeclaredFields":true
},
@@ -1418,7 +1393,7 @@
"methods":[{"name":"","parameterTypes":[] }, {"name":"setActualDataNodes","parameterTypes":["java.lang.String"] }, {"name":"setKeyGenerateStrategy","parameterTypes":["org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration"] }]
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.rule.DatabaseRulePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseRulePersistService"},
"name":"org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getActualDataNodes","parameterTypes":[] }, {"name":"getAuditStrategy","parameterTypes":[] }, {"name":"getDatabaseStrategy","parameterTypes":[] }, {"name":"getKeyGenerateStrategy","parameterTypes":[] }, {"name":"getLogicTable","parameterTypes":[] }, {"name":"getTableStrategy","parameterTypes":[] }]
@@ -1459,7 +1434,7 @@
"methods":[{"name":"","parameterTypes":[] }, {"name":"setStandard","parameterTypes":["org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration"] }]
},
{
- "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.rule.DatabaseRulePersistService"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseRulePersistService"},
"name":"org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getComplex","parameterTypes":[] }, {"name":"getHint","parameterTypes":[] }, {"name":"getNone","parameterTypes":[] }, {"name":"getStandard","parameterTypes":[] }]
@@ -1528,6 +1503,26 @@
"name":"org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration",
"allDeclaredFields":true
},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader"},
+ "name":"org.apache.shardingsphere.sql.parser.clickhouse.parser.ClickHouseLexer",
+ "methods":[{"name":"","parameterTypes":["org.antlr.v4.runtime.CharStream"] }]
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader"},
+ "name":"org.apache.shardingsphere.sql.parser.clickhouse.parser.ClickHouseParser",
+ "methods":[{"name":"","parameterTypes":["org.antlr.v4.runtime.TokenStream"] }]
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.sql.parser.core.database.visitor.SQLStatementVisitorFactory"},
+ "name":"org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitorFacade",
+ "methods":[{"name":"","parameterTypes":[] }]
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader"},
+ "name":"org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseDMLStatementVisitor",
+ "methods":[{"name":"","parameterTypes":[] }]
+},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sql.parser.core.database.cache.ParseTreeCacheBuilder"},
"name":"org.apache.shardingsphere.sql.parser.core.database.cache.ParseTreeCacheLoader"
@@ -1612,6 +1607,21 @@
"name":"org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.type.PostgreSQLDMLStatementVisitor",
"methods":[{"name":"","parameterTypes":[] }]
},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementBinder"},
+ "name":"org.apache.shardingsphere.sql.parser.sql.dialect.statement.clickhouse.dml.ClickHouseDeleteStatement",
+ "methods":[{"name":"","parameterTypes":[] }]
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement"},
+ "name":"org.apache.shardingsphere.sql.parser.sql.dialect.statement.clickhouse.dml.ClickHouseInsertStatement",
+ "methods":[{"name":"","parameterTypes":[] }]
+},
+{
+ "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement"},
+ "name":"org.apache.shardingsphere.sql.parser.sql.dialect.statement.clickhouse.dml.ClickHouseSelectStatement",
+ "methods":[{"name":"","parameterTypes":[] }]
+},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementBinder"},
"name":"org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLDeleteStatement",
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json
index db067f61bfa95c..e9293e80b97ee4 100644
--- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json
@@ -39,30 +39,6 @@
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"},
"pattern":"\\QMETA-INF/seata/io.seata.rm.AbstractRMHandler\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.rm.datasource.exec.InsertExecutor\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.rm.datasource.undo.UndoLogManager\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.rm.datasource.undo.UndoLogParser\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.rm.datasource.undo.parser.spi.JacksonSerializer\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.sqlparser.EscapeHandler\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.sqlparser.SQLRecognizerFactory\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.sqlparser.druid.SQLOperateRecognizerHolder\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/seata/io.seata.sqlparser.struct.TableMetaCache\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"},
"pattern":"\\QMETA-INF/seata/io.seata.sqlparser.util.DbTypeParser\\E"
@@ -108,30 +84,6 @@
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"},
"pattern":"\\QMETA-INF/services/io.seata.rm.AbstractRMHandler\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.rm.datasource.exec.InsertExecutor\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.rm.datasource.undo.UndoLogManager\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.rm.datasource.undo.UndoLogParser\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.rm.datasource.undo.parser.spi.JacksonSerializer\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.sqlparser.EscapeHandler\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.sqlparser.SQLRecognizerFactory\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.sqlparser.druid.SQLOperateRecognizerHolder\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$1"},
- "pattern":"\\QMETA-INF/services/io.seata.sqlparser.struct.TableMetaCache\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager"},
"pattern":"\\QMETA-INF/services/io.seata.sqlparser.util.DbTypeParser\\E"
@@ -208,7 +160,7 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.metadata.database.schema.reviser.schema.SchemaMetaDataReviseEngine"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.infra.metadata.database.schema.reviser.MetaDataReviseEntry\\E"
}, {
- "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContexts"},
+ "condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.infra.metadata.statistics.builder.ShardingSphereStatisticsBuilder\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry"},
@@ -260,7 +212,7 @@
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder"},
- "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.service.MetaDataManagerPersistServiceBuilder\\E"
+ "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory"},
"pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.spi.RuleNodePathProvider\\E"
@@ -2766,6 +2718,9 @@
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"},
"pattern":"\\Qsql\\E"
+ }, {
+ "condition":{"typeReachable":"org.apache.shardingsphere.infra.url.classpath.ClassPathURLLoader"},
+ "pattern":"\\Qtest-native/yaml/databases/clickhouse.yaml\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.url.classpath.ClassPathURLLoader"},
"pattern":"\\Qtest-native/yaml/databases/mysql.yaml\\E"
diff --git a/pom.xml b/pom.xml
index 9f74d4c8f6b48e..d539451795a734 100644
--- a/pom.xml
+++ b/pom.xml
@@ -125,6 +125,7 @@
2.2.224
3.1.0-og
2.4.2
+ 0.6.0-patch5
4.0.3
@@ -471,6 +472,13 @@
${h2.version}
test
+
+ com.clickhouse
+ clickhouse-jdbc
+ ${clickhouse-jdbc.version}
+ http
+ test
+
com.zaxxer
diff --git a/test/native/native-image-filter/extra-filter.json b/test/native/native-image-filter/extra-filter.json
index 864380209c8930..efcbfe3d48b151 100644
--- a/test/native/native-image-filter/extra-filter.json
+++ b/test/native/native-image-filter/extra-filter.json
@@ -18,6 +18,7 @@
{"excludeClasses": "com.arjuna.**"},
{"excludeClasses": "com.atomikos.**"},
{"excludeClasses": "com.alibaba.druid.**"},
+ {"excludeClasses": "com.clickhouse.jdbc.**"},
{"excludeClasses": "com.ctc.wstx.stax.**"},
{"excludeClasses": "com.fasterxml.jackson.databind.**"},
{"excludeClasses": "com.github.benmanes.caffeine.cache.**"},
diff --git a/test/native/pom.xml b/test/native/pom.xml
index 93e036a0c110a1..1266875230cdda 100644
--- a/test/native/pom.xml
+++ b/test/native/pom.xml
@@ -117,6 +117,12 @@ using Seata Client under GraalVM Native Image requires using the version release
+
+ org.apache.shardingsphere
+ shardingsphere-parser-sql-clickhouse
+ ${project.version}
+ test
+
org.awaitility
@@ -143,6 +149,12 @@ using Seata Client under GraalVM Native Image requires using the version release
mssql-jdbc
test
+
+ com.clickhouse
+ clickhouse-jdbc
+ http
+ test
+
org.testcontainers
postgresql
@@ -153,6 +165,11 @@ using Seata Client under GraalVM Native Image requires using the version release
mssqlserver
test
+
+ org.testcontainers
+ clickhouse
+ test
+
org.apache.curator
curator-test
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
index c9ca62e18d7cd6..8e577b480b3f18 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
@@ -36,6 +36,7 @@
import java.util.stream.LongStream;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
@Getter
@@ -55,7 +56,7 @@ public TestShardingService(final DataSource dataSource) {
/**
* Process success.
- *
+ *
* @throws SQLException An exception that provides information on a database access error or other errors.
*/
public void processSuccess() throws SQLException {
@@ -85,9 +86,43 @@ public void processSuccess() throws SQLException {
orderItemRepository.assertRollbackWithTransactions();
}
+ /**
+ * Process success in ClickHouse.
+ * ClickHouse has not fully supported transactions. Refer to ClickHouse/clickhouse-docs#2300.
+ * So ShardingSphere should not use {@code orderItemRepository.assertRollbackWithTransactions()} in the method here.
+ *
+ * @throws SQLException An exception that provides information on a database access error or other errors.
+ */
+ public void processSuccessInClickHouse() throws SQLException {
+ Collection orderIds = insertDataInClickHouse();
+ assertThat(orderIds, notNullValue());
+ Collection orders = orderRepository.selectAll();
+ assertThat(orders.stream().map(Order::getOrderType).collect(Collectors.toList()),
+ equalTo(Arrays.asList(1, 1, 1, 1, 1, 0, 0, 0, 0, 0)));
+ assertThat(orders.stream().map(Order::getUserId).collect(Collectors.toList()),
+ equalTo(new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9, 2, 4, 6, 8, 10))));
+ assertThat(orders.stream().map(Order::getAddressId).collect(Collectors.toList()),
+ equalTo(new ArrayList<>(Arrays.asList(1L, 3L, 5L, 7L, 9L, 2L, 4L, 6L, 8L, 10L))));
+ assertThat(orders.stream().map(Order::getStatus).collect(Collectors.toList()),
+ equalTo(IntStream.range(1, 11).mapToObj(i -> "INSERT_TEST").collect(Collectors.toList())));
+ Collection orderItems = orderItemRepository.selectAll();
+ assertThat(orderItems.stream().map(OrderItem::getUserId).collect(Collectors.toList()),
+ equalTo(new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9, 2, 4, 6, 8, 10))));
+ assertThat(orderItems.stream().map(OrderItem::getPhone).collect(Collectors.toList()),
+ equalTo(IntStream.range(1, 11).mapToObj(i -> "13800000001").collect(Collectors.toList())));
+ assertThat(orderItems.stream().map(OrderItem::getStatus).collect(Collectors.toList()),
+ equalTo(IntStream.range(1, 11).mapToObj(i -> "INSERT_TEST").collect(Collectors.toList())));
+ assertThat(addressRepository.selectAll(),
+ equalTo(LongStream.range(1L, 11L).mapToObj(each -> new Address(each, "address_test_" + each)).collect(Collectors.toList())));
+ deleteDataInClickHouse(orderIds);
+ assertThat(orderRepository.selectAll(), equalTo(Collections.emptyList()));
+ assertThat(orderItemRepository.selectAll(), equalTo(Collections.emptyList()));
+ assertThat(addressRepository.selectAll(), equalTo(Collections.emptyList()));
+ }
+
/**
* Insert data.
- *
+ *
* @return orderId of the insert statement.
* @throws SQLException An exception that provides information on a database access error or other errors.
*/
@@ -113,9 +148,37 @@ public Collection insertData() throws SQLException {
return result;
}
+ /**
+ * Insert data in ClickHouse.
+ *
+ * @return orderId of the insert statement.
+ * @throws SQLException An exception that provides information on a database access error or other errors.
+ */
+ public Collection insertDataInClickHouse() throws SQLException {
+ Collection result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ Order order = new Order();
+ order.setUserId(i);
+ order.setOrderType(i % 2);
+ order.setAddressId(i);
+ order.setStatus("INSERT_TEST");
+ orderRepository.insertWithoutAutoGeneratedKey(order);
+ OrderItem orderItem = new OrderItem();
+ orderItem.setOrderId(order.getOrderId());
+ orderItem.setUserId(i);
+ orderItem.setPhone("13800000001");
+ orderItem.setStatus("INSERT_TEST");
+ orderItemRepository.insertWithoutAutoGeneratedKey(orderItem);
+ Address address = new Address((long) i, "address_test_" + i);
+ addressRepository.insert(address);
+ result.add(order.getOrderId());
+ }
+ return result;
+ }
+
/**
* Delete data.
- *
+ *
* @param orderIds orderId of the insert statement.
* @throws SQLException An exception that provides information on a database access error or other errors.
*/
@@ -128,9 +191,24 @@ public void deleteData(final Collection orderIds) throws SQLException {
}
}
+ /**
+ * Delete data in ClickHouse.
+ *
+ * @param orderIds orderId of the insert statement.
+ * @throws SQLException An exception that provides information on a database access error or other errors.
+ */
+ public void deleteDataInClickHouse(final Collection orderIds) throws SQLException {
+ long count = 1L;
+ for (Long each : orderIds) {
+ orderRepository.deleteInClickHouse(each);
+ orderItemRepository.deleteInClickHouse(each);
+ addressRepository.deleteInClickHouse(count++);
+ }
+ }
+
/**
* Clean environment.
- *
+ *
* @throws SQLException An exception that provides information on a database access error or other errors.
*/
public void cleanEnvironment() throws SQLException {
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java
index 4c6f5f2c124b58..1e519f617a7582 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/AddressRepository.java
@@ -133,6 +133,22 @@ public void delete(final Long id) throws SQLException {
}
}
+ /**
+ * delete by id in ClickHouse.
+ *
+ * @param id id
+ * @throws SQLException SQL exception
+ */
+ public void deleteInClickHouse(final Long id) throws SQLException {
+ String sql = "alter table t_address delete where address_id=?";
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setLong(1, id);
+ preparedStatement.executeUpdate();
+ }
+ }
+
/**
* select all.
*
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderItemRepository.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderItemRepository.java
index f708decf509663..8979e284eff261 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderItemRepository.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderItemRepository.java
@@ -42,11 +42,17 @@ public OrderItemRepository(final DataSource dataSource) {
/**
* create table if not exists in MySQL.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsInMySQL() throws SQLException {
- String sql = "CREATE TABLE IF NOT EXISTS t_order_item "
- + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY KEY (order_item_id))";
+ String sql = "CREATE TABLE IF NOT EXISTS t_order_item \n"
+ + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT,\n"
+ + "order_id BIGINT NOT NULL,\n"
+ + "user_id INT NOT NULL,\n"
+ + "phone VARCHAR(50),\n"
+ + "status VARCHAR(50),\n"
+ + "PRIMARY KEY (order_item_id));";
try (
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
@@ -56,6 +62,7 @@ public void createTableIfNotExistsInMySQL() throws SQLException {
/**
* create table if not exists in Postgres.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsInPostgres() throws SQLException {
@@ -76,6 +83,7 @@ public void createTableIfNotExistsInPostgres() throws SQLException {
/**
* create table in MS SQL Server. `order_item_id` is not set to `IDENTITY(1,1)` to simplify the unit test.
* This also ignored the default schema of the `dbo`.
+ *
* @throws SQLException SQL exception
*/
public void createTableInSQLServer() throws SQLException {
@@ -94,8 +102,31 @@ public void createTableInSQLServer() throws SQLException {
}
}
+ /**
+ * create table if not exists in ClickHouse.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void createTableIfNotExistsInClickHouse() throws SQLException {
+ String sql = "create table IF NOT EXISTS t_order_item( \n"
+ + "order_item_id Int64 NOT NULL DEFAULT rand(), \n"
+ + "order_id Int64 NOT NULL, \n"
+ + "user_id Int32 NOT NULL, \n"
+ + "phone String,\n"
+ + "status String\n"
+ + ") engine = MergeTree \n"
+ + "primary key (order_item_id)\n"
+ + "order by(order_item_id); ";
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ }
+ }
+
/**
* drop table.
+ *
* @throws SQLException SQL exception
*/
public void dropTable() throws SQLException {
@@ -109,6 +140,7 @@ public void dropTable() throws SQLException {
/**
* truncate table.
+ *
* @throws SQLException SQL exception
*/
public void truncateTable() throws SQLException {
@@ -122,6 +154,7 @@ public void truncateTable() throws SQLException {
/**
* create shadow table if not exists.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsShadow() throws SQLException {
@@ -137,6 +170,7 @@ public void createTableIfNotExistsShadow() throws SQLException {
/**
* drop shadow table.
+ *
* @throws SQLException SQL exception
*/
public void dropTableShadow() throws SQLException {
@@ -150,6 +184,7 @@ public void dropTableShadow() throws SQLException {
/**
* truncate shadow table.
+ *
* @throws SQLException SQL exception
*/
public void truncateTableShadow() throws SQLException {
@@ -162,16 +197,32 @@ public void truncateTableShadow() throws SQLException {
}
/**
- * insert something to table.
+ * insert OrderItem to table.
+ *
* @param orderItem orderItem
* @return orderItemId of the insert statement
- * @throws SQLException SQL exception
+ * @throws SQLException SQL Exception
*/
public Long insert(final OrderItem orderItem) throws SQLException {
+ return insert(orderItem, Statement.RETURN_GENERATED_KEYS);
+ }
+
+ /**
+ * insert OrderItem to table.
+ *
+ * @param orderItem orderItem
+ * @param autoGeneratedKeys a flag indicating whether auto-generated keys
+ * should be returned; one of
+ * {@code Statement.RETURN_GENERATED_KEYS} or
+ * {@code Statement.NO_GENERATED_KEYS}
+ * @return orderItemId of the insert statement
+ * @throws SQLException SQL exception
+ */
+ public Long insert(final OrderItem orderItem, final int autoGeneratedKeys) throws SQLException {
String sql = "INSERT INTO t_order_item (order_id, user_id, phone, status) VALUES (?, ?, ?, ?)";
try (
Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, autoGeneratedKeys)) {
preparedStatement.setLong(1, orderItem.getOrderId());
preparedStatement.setInt(2, orderItem.getUserId());
preparedStatement.setString(3, orderItem.getPhone());
@@ -186,8 +237,20 @@ public Long insert(final OrderItem orderItem) throws SQLException {
return orderItem.getOrderItemId();
}
+ /**
+ * insert OrderItem to table without auto generated key. Databases like ClickHouse do not support returning auto generated keys after executing SQL,
+ * see ClickHouse/ClickHouse#56228 .
+ *
+ * @param orderItem orderItem
+ * @throws SQLException SQL Exception
+ */
+ public void insertWithoutAutoGeneratedKey(final OrderItem orderItem) throws SQLException {
+ insert(orderItem, Statement.NO_GENERATED_KEYS);
+ }
+
/**
* delete by orderItemId.
+ *
* @param orderItemId orderItemId
* @throws SQLException SQL exception
*/
@@ -201,8 +264,25 @@ public void delete(final Long orderItemId) throws SQLException {
}
}
+ /**
+ * delete by orderItemId in ClickHouse.
+ *
+ * @param orderItemId orderItemId
+ * @throws SQLException SQL exception
+ */
+ public void deleteInClickHouse(final Long orderItemId) throws SQLException {
+ String sql = "alter table t_order_item delete where order_id=?";
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setLong(1, orderItemId);
+ preparedStatement.executeUpdate();
+ }
+ }
+
/**
* select all.
+ *
* @return list of OrderItem
* @throws SQLException SQL exception
*/
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderRepository.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderRepository.java
index 099ff83753780f..0919940a716618 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderRepository.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/repository/OrderRepository.java
@@ -39,11 +39,17 @@ public OrderRepository(final DataSource dataSource) {
/**
* create table if not exists in MySQL.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsInMySQL() throws SQLException {
- String sql = "CREATE TABLE IF NOT EXISTS t_order "
- + "(order_id BIGINT NOT NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id))";
+ String sql = "CREATE TABLE IF NOT EXISTS t_order\n"
+ + "(order_id BIGINT NOT NULL AUTO_INCREMENT,\n"
+ + "order_type INT(11),\n"
+ + "user_id INT NOT NULL,\n"
+ + "address_id BIGINT NOT NULL,\n"
+ + "status VARCHAR(50),\n"
+ + "PRIMARY KEY (order_id));";
try (
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
@@ -53,6 +59,7 @@ public void createTableIfNotExistsInMySQL() throws SQLException {
/**
* create table if not exists in Postgres.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsInPostgres() throws SQLException {
@@ -73,12 +80,13 @@ public void createTableIfNotExistsInPostgres() throws SQLException {
/**
* create table in MS SQL Server. `order_item_id` is not set to `IDENTITY(1,1)` to simplify the unit test.
* This also ignored the default schema of the `dbo`.
+ *
* @throws SQLException SQL exception
*/
public void createTableInSQLServer() throws SQLException {
String sql = "CREATE TABLE [t_order] (\n"
+ " order_id bigint NOT NULL,\n"
- + " order_type int NOT NULL,\n"
+ + " order_type int,\n"
+ " user_id int NOT NULL,\n"
+ " address_id bigint NOT NULL,\n"
+ " status varchar(50),\n"
@@ -91,9 +99,32 @@ public void createTableInSQLServer() throws SQLException {
}
}
+ /**
+ * create table in ClickHouse.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void createTableIfNotExistsInClickHouse() throws SQLException {
+ String sql = "create table IF NOT EXISTS t_order( \n"
+ + "order_id Int64 NOT NULL DEFAULT rand(), \n"
+ + "order_type Int32, \n"
+ + "user_id Int32 NOT NULL, \n"
+ + "address_id Int64 NOT NULL,\n"
+ + "status String\n"
+ + ") engine = MergeTree \n"
+ + "primary key (order_id)\n"
+ + "order by(order_id); ";
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ }
+ }
+
/**
* drop table.
* TODO There is a bug in this function in shadow's unit test and requires additional fixes.
+ *
* @throws SQLException SQL exception
*/
public void dropTable() throws SQLException {
@@ -107,6 +138,7 @@ public void dropTable() throws SQLException {
/**
* truncate table.
+ *
* @throws SQLException SQL exception
*/
public void truncateTable() throws SQLException {
@@ -120,6 +152,7 @@ public void truncateTable() throws SQLException {
/**
* create shadow table if not exists.
+ *
* @throws SQLException SQL exception
*/
public void createTableIfNotExistsShadow() throws SQLException {
@@ -136,6 +169,7 @@ public void createTableIfNotExistsShadow() throws SQLException {
/**
* drop shadow table.
+ *
* @throws SQLException SQL exception
*/
public void dropTableShadow() throws SQLException {
@@ -149,6 +183,7 @@ public void dropTableShadow() throws SQLException {
/**
* truncate shadow table.
+ *
* @throws SQLException SQL exception
*/
public void truncateTableShadow() throws SQLException {
@@ -162,6 +197,7 @@ public void truncateTableShadow() throws SQLException {
/**
* select Order from shadow table.
+ *
* @return list of Order
* @throws SQLException SQL exception
*/
@@ -172,6 +208,7 @@ public List selectShadowOrder() throws SQLException {
/**
* delete Order from shadow table.
+ *
* @param orderId orderId
* @throws SQLException SQL Exception
*/
@@ -187,15 +224,31 @@ public void deleteShadow(final Long orderId) throws SQLException {
/**
* insert Order to table.
+ *
* @param order order
* @return orderId of the insert statement
* @throws SQLException SQL Exception
*/
public Long insert(final Order order) throws SQLException {
+ return insert(order, Statement.RETURN_GENERATED_KEYS);
+ }
+
+ /**
+ * insert Order to table.
+ *
+ * @param order order
+ * @param autoGeneratedKeys a flag indicating whether auto-generated keys
+ * should be returned; one of
+ * {@code Statement.RETURN_GENERATED_KEYS} or
+ * {@code Statement.NO_GENERATED_KEYS}
+ * @return orderId of the insert statement
+ * @throws SQLException SQL Exception
+ */
+ public Long insert(final Order order, final int autoGeneratedKeys) throws SQLException {
String sql = "INSERT INTO t_order (user_id, order_type, address_id, status) VALUES (?, ?, ?, ?)";
try (
Connection connection = dataSource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, autoGeneratedKeys)) {
preparedStatement.setInt(1, order.getUserId());
preparedStatement.setInt(2, order.getOrderType());
preparedStatement.setLong(3, order.getAddressId());
@@ -210,8 +263,20 @@ public Long insert(final Order order) throws SQLException {
return order.getOrderId();
}
+ /**
+ * insert Order to table without auto generated key. Databases like ClickHouse do not support returning auto generated keys after executing SQL,
+ * see ClickHouse/ClickHouse#56228 .
+ *
+ * @param order order
+ * @throws SQLException SQL Exception
+ */
+ public void insertWithoutAutoGeneratedKey(final Order order) throws SQLException {
+ insert(order, Statement.NO_GENERATED_KEYS);
+ }
+
/**
* delete by orderId.
+ *
* @param orderId orderId
* @throws SQLException SQL exception
*/
@@ -225,8 +290,25 @@ public void delete(final Long orderId) throws SQLException {
}
}
+ /**
+ * delete by orderId in ClickHouse.
+ *
+ * @param orderId orderId
+ * @throws SQLException SQL exception
+ */
+ public void deleteInClickHouse(final Long orderId) throws SQLException {
+ String sql = "alter table t_order delete where order_id=?";
+ try (
+ Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setLong(1, orderId);
+ preparedStatement.executeUpdate();
+ }
+ }
+
/**
* select all.
+ *
* @return list of Order
* @throws SQLException SQL exception
*/
@@ -236,6 +318,7 @@ public List selectAll() throws SQLException {
/**
* get Orders by SQL.
+ *
* @param sql SQL
* @return list of Order
* @throws SQLException SQL exception
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/testcontainers/ClickHouseProvider.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/testcontainers/ClickHouseProvider.java
new file mode 100644
index 00000000000000..e9ec54e963000b
--- /dev/null
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/testcontainers/ClickHouseProvider.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.test.natived.jdbc.commons.testcontainers;
+
+import org.testcontainers.clickhouse.ClickHouseContainer;
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.JdbcDatabaseContainerProvider;
+import org.testcontainers.utility.DockerImageName;
+
+/**
+ * TODO Initialize a new JdbcDatabaseContainerProvider implementation due to
+ * testcontainers/testcontainers-java#8736 not closed.
+ */
+public final class ClickHouseProvider extends JdbcDatabaseContainerProvider {
+
+ /**
+ * The reason for using `0` as the separator is that the URL_MATCHING_PATTERN of the {@link org.testcontainers.jdbc.ConnectionUrl.Patterns}
+ * sets {@code "(?[a-z0-9]+)"} for the `databaseType` part.
+ *
+ * @param databaseType {@link String}
+ * @return true
when provider can handle this database type, else false
.
+ */
+ @Override
+ public boolean supports(final String databaseType) {
+ return "shardingsphere0clickhouse".equals(databaseType);
+ }
+
+ @Override
+ public JdbcDatabaseContainer> newInstance(final String tag) {
+ return new ClickHouseContainer(DockerImageName.parse("clickhouse/clickhouse-server").withTag(tag));
+ }
+}
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/ClickHouseTest.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/ClickHouseTest.java
new file mode 100644
index 00000000000000..0c526f833d94df
--- /dev/null
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/ClickHouseTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.test.natived.jdbc.databases;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledInNativeImage;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+class ClickHouseTest {
+
+ private TestShardingService testShardingService;
+
+ /**
+ * TODO Need to fix `shardingsphere-parser-sql-clickhouse` module to use `testShardingService.cleanEnvironment()`
+ * after `testShardingService.processSuccessInClickHouse()`.
+ *
+ * @throws SQLException An exception that provides information on a database access error or other errors.
+ */
+ @EnabledInNativeImage
+ @Test
+ void assertShardingInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+ config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+ config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/databases/clickhouse.yaml");
+ DataSource dataSource = new HikariDataSource(config);
+ testShardingService = new TestShardingService(dataSource);
+ testShardingService.processSuccessInClickHouse();
+ }
+
+ /**
+ * TODO Need to fix `shardingsphere-parser-sql-clickhouse` module to use `initEnvironment()`
+ * before `testShardingService.processSuccess()`.
+ *
+ * @throws SQLException An exception that provides information on a database access error or other errors.
+ */
+ @SuppressWarnings("unused")
+ private void initEnvironment() throws SQLException {
+ testShardingService.getOrderRepository().createTableIfNotExistsInClickHouse();
+ testShardingService.getOrderItemRepository().createTableIfNotExistsInClickHouse();
+ testShardingService.getAddressRepository().createTableIfNotExists();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
+ }
+}
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/EtcdTest.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/EtcdTest.java
index 325047d48ff760..bc11505a5e7a9e 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/EtcdTest.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/EtcdTest.java
@@ -29,8 +29,8 @@
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledInNativeImage;
import javax.sql.DataSource;
import java.io.IOException;
@@ -53,11 +53,12 @@ class EtcdTest {
* TODO On low-performance devices in Github Actions, `INSERT` related SQLs may throw a table not found error under nativeTest.
* So that we need to wait for a period of time after executing `CREATE TABLE` related SQLs before executing `INSERT` related SQLs.
* This may mean that the implementation of {@link org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository} needs optimization.
+ * TODO For unknown reasons, this unit test fails under GraalVM Native Image.
*
* @see org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository
*/
@Test
- @EnabledInNativeImage
+ @Disabled
void assertShardingInLocalTransactions() throws SQLException {
try (
EtcdCluster etcd = Etcd.builder()
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/ZookeeperTest.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/ZookeeperTest.java
index 9c9d1d5617cefe..4434bd84c64321 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/ZookeeperTest.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/modes/cluster/ZookeeperTest.java
@@ -26,6 +26,7 @@
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledInNativeImage;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -46,10 +47,12 @@ class ZookeeperTest {
* TODO On low-performance devices in Github Actions, `INSERT` related SQLs may throw a table not found error under nativeTest.
* So that we need to wait for a period of time after executing `CREATE TABLE` related SQLs before executing `INSERT` related SQLs.
* This may mean that the implementation of {@link org.apache.shardingsphere.mode.repository.cluster.zookeeper.ZookeeperRepository} needs optimization.
+ * TODO For unknown reasons, this unit test fails under GraalVM Native Image.
*
* @see org.apache.shardingsphere.mode.repository.cluster.zookeeper.ZookeeperRepository
*/
@Test
+ @DisabledInNativeImage
void assertShardingInLocalTransactions() throws Exception {
try (TestingServer testingServer = new TestingServer()) {
String connectString = testingServer.getConnectString();
diff --git a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json
index 95ee064bc5d98b..5a22d077ea78e5 100644
--- a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json
+++ b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json
@@ -2,52 +2,16 @@
"resources":{
"includes":[{
"condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.databases.SQLServerTest"},
- "pattern":"\\Qcontainer-license-acceptance.txt\\E"
+ "pattern":".*test-native/yaml/.+\\.yaml$"
}, {
- "condition":{"typeReachable":"ch.qos.logback.core.util.Loader"},
- "pattern":"\\Qlogback-test.xml\\E"
+ "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"},
+ "pattern":".*test-native/sql/.+\\.sql$"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.databases.SQLServerTest"},
- "pattern":"\\Qtest-native/yaml/databases/sqlserver.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.databases.MySQLTest"},
- "pattern":"\\Qtest-native/yaml/databases/mysql.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.databases.OpenGaussTest"},
- "pattern":"\\Qtest-native/yaml/databases/opengauss.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.databases.PostgresTest"},
- "pattern":"\\Qtest-native/yaml/databases/postgresql.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.features.EncryptTest"},
- "pattern":"\\Qtest-native/yaml/features/encrypt.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.features.MaskTest"},
- "pattern":"\\Qtest-native/yaml/features/mask.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.features.ReadWriteSplittingTest"},
- "pattern":"\\Qtest-native/yaml/features/readwrite-splitting.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.features.ShadowTest"},
- "pattern":"\\Qtest-native/yaml/features/shadow.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.features.ShardingTest"},
- "pattern":"\\Qtest-native/yaml/features/sharding.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest"},
- "pattern":"\\Qtest-native/yaml/modes/cluster/zookeeper.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest"},
- "pattern":"\\Qtest-native/yaml/modes/cluster/etcd.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.xa.AtomikosTest"},
- "pattern":"\\Qtest-native/yaml/transactions/xa/atomikos.yaml\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.xa.NarayanaTest"},
- "pattern":"\\Qtest-native/yaml/transactions/xa/narayana.yaml\\E"
+ "pattern":"\\Qcontainer-license-acceptance.txt\\E"
}, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"},
- "pattern":"\\Qtest-native/yaml/transactions/base/seata.yaml\\E"
+ "condition":{"typeReachable":"ch.qos.logback.core.util.Loader"},
+ "pattern":"\\Qlogback-test.xml\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"},
"pattern":"\\Qseata-script-client-conf-file.conf\\E"
@@ -57,9 +21,6 @@
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"},
"pattern":"\\Qseata.conf\\E"
- }, {
- "condition":{"typeReachable":"org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest"},
- "pattern":"\\Qtest-native/sql/seata-script-client-at-postgresql.sql\\E"
}]},
"bundles":[]
}
diff --git a/test/native/src/test/resources/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider b/test/native/src/test/resources/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider
new file mode 100644
index 00000000000000..a4a4667b0e4f5e
--- /dev/null
+++ b/test/native/src/test/resources/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.test.natived.jdbc.commons.testcontainers.ClickHouseProvider
diff --git a/test/native/src/test/resources/test-native/sql/test-native-databases-clickhouse.sql b/test/native/src/test/resources/test-native/sql/test-native-databases-clickhouse.sql
new file mode 100644
index 00000000000000..09c5647a739833
--- /dev/null
+++ b/test/native/src/test/resources/test-native/sql/test-native-databases-clickhouse.sql
@@ -0,0 +1,49 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You 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.
+--
+
+create table IF NOT EXISTS t_order
+(
+ order_id Int64 NOT NULL DEFAULT rand(),
+ order_type Int32,
+ user_id Int32 NOT NULL,
+ address_id Int64 NOT NULL,
+ status String
+) engine = MergeTree
+ primary key (order_id)
+ order by (order_id);
+
+create table IF NOT EXISTS t_order_item
+(
+ order_item_id Int64 NOT NULL DEFAULT rand(),
+ order_id Int64 NOT NULL,
+ user_id Int32 NOT NULL,
+ phone String,
+ status String
+) engine = MergeTree
+ primary key (order_item_id)
+ order by (order_item_id);
+
+CREATE TABLE IF NOT EXISTS t_address
+(
+ address_id BIGINT NOT NULL,
+ address_name VARCHAR(100) NOT NULL,
+ PRIMARY KEY (address_id)
+);
+
+TRUNCATE TABLE t_order;
+TRUNCATE TABLE t_order_item;
+TRUNCATE TABLE t_address;
diff --git a/test/native/src/test/resources/test-native/yaml/databases/clickhouse.yaml b/test/native/src/test/resources/test-native/yaml/databases/clickhouse.yaml
new file mode 100644
index 00000000000000..a6989339adacb7
--- /dev/null
+++ b/test/native/src/test/resources/test-native/yaml/databases/clickhouse.yaml
@@ -0,0 +1,73 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+mode:
+ type: Standalone
+ repository:
+ type: JDBC
+
+# TODO See the JavaDoc for `org.apache.shardingsphere.test.natived.jdbc.commons.testcontainers.ClickHouseProvider`.
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
+ jdbcUrl: jdbc:tc:shardingsphere0clickhouse:24.4.1.2088://test-native-databases-clickhouse/demo_ds_0?TC_INITSCRIPT=test-native/sql/test-native-databases-clickhouse.sql
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
+ jdbcUrl: jdbc:tc:shardingsphere0clickhouse:24.4.1.2088://test-native-databases-clickhouse/demo_ds_1?TC_INITSCRIPT=test-native/sql/test-native-databases-clickhouse.sql
+ ds_2:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
+ jdbcUrl: jdbc:tc:shardingsphere0clickhouse:24.4.1.2088://test-native-databases-clickhouse/demo_ds_2?TC_INITSCRIPT=test-native/sql/test-native-databases-clickhouse.sql
+
+rules:
+ - !SHARDING
+ tables:
+ t_order:
+ actualDataNodes:
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes:
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: inline
+ shardingAlgorithms:
+ inline:
+ type: CLASS_BASED
+ props:
+ strategy: STANDARD
+ algorithmClassName: org.apache.shardingsphere.test.natived.jdbc.commons.algorithm.ClassBasedInlineShardingAlgorithmFixture
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+ auditors:
+ sharding_key_required_auditor:
+ type: DML_SHARDING_CONDITIONS
+
+ - !BROADCAST
+ tables:
+ - t_address
+
+props:
+ sql-show: false