World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#9738] feat(clickhouse): Add skeleton for Clickhouse catalog (#9742)
Mini Yu43ac3742a099
diff --git a/build.gradle.kts b/build.gradle.ktsindex 91cc97ea0a..f06c46acc5 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -1114,7 +1114,6 @@ tasks {":catalogs:catalog-hive:copyLibAndConfig",":catalogs:catalog-jdbc-doris:copyLibAndConfig",":catalogs:catalog-jdbc-mysql:copyLibAndConfig",- ":catalogs-contrib:catalog-jdbc-oceanbase:copyLibAndConfig",":catalogs:catalog-jdbc-postgresql:copyLibAndConfig",":catalogs:catalog-jdbc-starrocks:copyLibAndConfig",":catalogs:catalog-kafka:copyLibAndConfig",@@ -1124,7 +1123,9 @@ tasks {":catalogs:catalog-model:copyLibAndConfig",":catalogs:hive-metastore2-libs:copyLibs",":catalogs:hive-metastore3-libs:copyLibs",- ":catalogs:catalog-lakehouse-generic:copyLibAndConfig"+ ":catalogs:catalog-lakehouse-generic:copyLibAndConfig",+ ":catalogs-contrib:catalog-jdbc-oceanbase:copyLibAndConfig",+ ":catalogs-contrib:catalog-jdbc-clickhouse:copyLibAndConfig")}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/build.gradle.kts b/catalogs-contrib/catalog-jdbc-clickhouse/build.gradle.ktsnew file mode 100644index 0000000000..94de7b8b15--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/build.gradle.kts@@ -0,0 +1,104 @@+/*+ * 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.+ */+description = "catalog-jdbc-clickhouse"++plugins {+ `maven-publish`+ id("java")+ id("idea")+}++dependencies {+ implementation(project(":api")) {+ exclude(group = "*")+ }+ implementation(project(":catalogs:catalog-jdbc-common")) {+ exclude(group = "*")+ }+ implementation(project(":common")) {+ exclude(group = "*")+ }+ implementation(project(":core")) {+ exclude(group = "*")+ }++ implementation(libs.bundles.log4j)+ implementation(libs.commons.collections4)+ implementation(libs.commons.lang3)+ implementation(libs.guava)++ testImplementation(project(":catalogs:catalog-jdbc-common", "testArtifacts"))+ testImplementation(project(":clients:client-java"))+ testImplementation(project(":integration-test-common", "testArtifacts"))+ testImplementation(project(":server"))+ testImplementation(project(":server-common"))++ testImplementation(libs.awaitility)+ testImplementation(libs.junit.jupiter.api)+ testImplementation(libs.junit.jupiter.params)+ testImplementation(libs.testcontainers)++ testRuntimeOnly(libs.junit.jupiter.engine)+}++tasks {+ register("runtimeJars", Copy::class) {+ from(configurations.runtimeClasspath)+ into("build/libs")+ }++ val copyCatalogLibs by registering(Copy::class) {+ dependsOn("jar", "runtimeJars")+ from("build/libs") {+ exclude("guava-*.jar")+ exclude("log4j-*.jar")+ exclude("slf4j-*.jar")+ }+ into("$rootDir/distribution/package/catalogs/jdbc-clickhouse/libs")+ }++ val copyCatalogConfig by registering(Copy::class) {+ from("src/main/resources")+ into("$rootDir/distribution/package/catalogs/jdbc-clickhouse/conf")++ include("jdbc-clickhouse.conf")++ exclude { details -> details.file.isDirectory() }++ fileMode = 0b111101101+ }++ register("copyLibAndConfig", Copy::class) {+ dependsOn(copyCatalogLibs, copyCatalogConfig)+ }+}++tasks.test {+ val skipITs = project.hasProperty("skipITs")+ if (skipITs) {+ // Exclude integration tests+ exclude("**/integration/test/**")+ } else {+ dependsOn(tasks.jar)+ }+}++tasks.getByName("generateMetadataFileForMavenJavaPublication") {+ dependsOn("runtimeJars")+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalog.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalog.javanew file mode 100644index 0000000000..8d547c2aa0--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalog.java@@ -0,0 +1,70 @@+/*+ * 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.gravitino.catalog.clickhouse;++import org.apache.gravitino.catalog.clickhouse.converter.ClickHouseColumnDefaultValueConverter;+import org.apache.gravitino.catalog.clickhouse.converter.ClickHouseExceptionConverter;+import org.apache.gravitino.catalog.clickhouse.converter.ClickHouseTypeConverter;+import org.apache.gravitino.catalog.clickhouse.operations.ClickHouseDatabaseOperations;+import org.apache.gravitino.catalog.clickhouse.operations.ClickHouseTableOperations;+import org.apache.gravitino.catalog.jdbc.JdbcCatalog;+import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;+import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;+import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;+import org.apache.gravitino.connector.capability.Capability;++public class ClickHouseCatalog extends JdbcCatalog {++ @Override+ public String shortName() {+ return "jdbc-clickhouse";+ }++ @Override+ protected JdbcExceptionConverter createExceptionConverter() {+ return new ClickHouseExceptionConverter();+ }++ @Override+ protected JdbcTypeConverter createJdbcTypeConverter() {+ return new ClickHouseTypeConverter();+ }++ @Override+ protected JdbcDatabaseOperations createJdbcDatabaseOperations() {+ return new ClickHouseDatabaseOperations();+ }++ @Override+ protected JdbcTableOperations createJdbcTableOperations() {+ return new ClickHouseTableOperations();+ }++ @Override+ protected JdbcColumnDefaultValueConverter createJdbcColumnDefaultValueConverter() {+ return new ClickHouseColumnDefaultValueConverter();+ }++ @Override+ public Capability newCapability() {+ return new ClickHouseCatalogCapability();+ }+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalogCapability.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalogCapability.javanew file mode 100644index 0000000000..8ce7478945--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/ClickHouseCatalogCapability.java@@ -0,0 +1,26 @@+/*+ * 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.gravitino.catalog.clickhouse;++import org.apache.gravitino.catalog.jdbc.JdbcCatalogCapability;++public class ClickHouseCatalogCapability extends JdbcCatalogCapability {+ // No additional capabilities for ClickHouse at this time+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseColumnDefaultValueConverter.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseColumnDefaultValueConverter.javanew file mode 100644index 0000000000..121f40cca3--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseColumnDefaultValueConverter.java@@ -0,0 +1,25 @@+/*+ * 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.gravitino.catalog.clickhouse.converter;++import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;++public class ClickHouseColumnDefaultValueConverter extends JdbcColumnDefaultValueConverter {+ // Implement ClickHouse specific default value conversions if needed+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseExceptionConverter.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseExceptionConverter.javanew file mode 100644index 0000000000..5da5170dd9--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseExceptionConverter.java@@ -0,0 +1,25 @@+/*+ * 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.gravitino.catalog.clickhouse.converter;++import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;++public class ClickHouseExceptionConverter extends JdbcExceptionConverter {+ // Implement ClickHouse specific exception conversions if needed+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseTypeConverter.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseTypeConverter.javanew file mode 100644index 0000000000..26196685df--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseTypeConverter.java@@ -0,0 +1,37 @@+/*+ * 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.gravitino.catalog.clickhouse.converter;++import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;+import org.apache.gravitino.rel.types.Type;++public class ClickHouseTypeConverter extends JdbcTypeConverter {++ @Override+ public String fromGravitino(Type type) {+ throw new UnsupportedOperationException(+ "ClickHouseTypeConverter.fromGravitino is not implemented yet.");+ }++ @Override+ public Type toGravitino(JdbcTypeBean jdbcTypeBean) {+ throw new UnsupportedOperationException(+ "ClickHouseTypeConverter.toGravitino is not implemented yet.");+ }+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseDatabaseOperations.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseDatabaseOperations.javanew file mode 100644index 0000000000..bc0569bea7--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseDatabaseOperations.java@@ -0,0 +1,36 @@+/*+ * 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.gravitino.catalog.clickhouse.operations;++import com.google.common.collect.Sets;+import java.util.Set;+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;++public class ClickHouseDatabaseOperations extends JdbcDatabaseOperations {++ @Override+ protected boolean supportSchemaComment() {+ return false;+ }++ @Override+ protected Set<String> createSysDatabaseNameSet() {+ return Sets.newHashSet();+ }+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.javanew file mode 100644index 0000000000..39e5a7c666--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java@@ -0,0 +1,56 @@+/*+ * 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.gravitino.catalog.clickhouse.operations;++import java.util.Map;+import org.apache.gravitino.catalog.jdbc.JdbcColumn;+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;+import org.apache.gravitino.rel.TableChange;+import org.apache.gravitino.rel.expressions.distributions.Distribution;+import org.apache.gravitino.rel.expressions.transforms.Transform;+import org.apache.gravitino.rel.indexes.Index;++public class ClickHouseTableOperations extends JdbcTableOperations {++ @Override+ protected String generateCreateTableSql(+ String tableName,+ JdbcColumn[] columns,+ String comment,+ Map<String, String> properties,+ Transform[] partitioning,+ Distribution distribution,+ Index[] indexes) {+ throw new UnsupportedOperationException(+ "ClickHouseTableOperations.generateCreateTableSql is not implemented yet.");+ }++ @Override+ protected String generatePurgeTableSql(String tableName) {+ throw new UnsupportedOperationException(+ "ClickHouseTableOperations.generatePurgeTableSql is not implemented yet.");+ }++ @Override+ protected String generateAlterTableSql(+ String databaseName, String tableName, TableChange... changes) {+ throw new UnsupportedOperationException(+ "ClickHouseTableOperations.generateAlterTableSql is not implemented yet.");+ }+}diff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvider b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvidernew file mode 100644index 0000000000..02ccbb2b0c--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvider@@ -0,0 +1,19 @@+#+# 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.gravitino.catalog.clickhouse.ClickHouseCatalogdiff --git a/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/jdbc-clickhouse.conf b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/jdbc-clickhouse.confnew file mode 100644index 0000000000..a9f227969f--- /dev/null+++ b/catalogs-contrib/catalog-jdbc-clickhouse/src/main/resources/jdbc-clickhouse.conf@@ -0,0 +1,22 @@+#+# 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.+#+# jdbc-url = jdbc:clickhouse://localhost:8443/default+# jdbc-user = default+# jdbc-password = ""+# jdbc-driver = com.clickhouse.jdbc.ClickHouseDriverdiff --git a/settings.gradle.kts b/settings.gradle.ktsindex bc6f7c3052..0d9b185801 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -41,11 +41,14 @@ include("catalogs:catalog-jdbc-postgresql","catalogs:catalog-jdbc-starrocks")-include("catalogs-contrib:catalog-jdbc-oceanbase")include("catalogs:catalog-fileset")include("catalogs:catalog-kafka")include("catalogs:catalog-model")++include("catalogs-contrib:catalog-jdbc-clickhouse")+include("catalogs-contrib:catalog-jdbc-oceanbase")+include("clients:client-java","clients:client-java-runtime",