yuqi1129 commented on code in PR #10517:
URL: https://github.com/apache/gravitino/pull/10517#discussion_r3124769170
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/store/GravitinoCatalogStore.java:
##########
@@ -160,8 +185,13 @@ private BaseCatalogFactory
discoverFactories(Predicate<Factory> predicate, Strin
if (catalogFactory instanceof BaseCatalogFactory &&
predicate.test(catalogFactory)) {
factories.add(catalogFactory);
}
+ } catch (ServiceConfigurationError e) {
+ LOG.debug(
+ "Skip a {} entry that cannot be initialized.",
Factory.class.getCanonicalName(), e);
} catch (NoClassDefFoundError e) {
LOG.debug("NoClassDefFoundError when loading a {}.",
Factory.class.getCanonicalName(), e);
+ } catch (LinkageError e) {
+ LOG.debug("LinkageError when loading a {}.",
Factory.class.getCanonicalName(), e);
Review Comment:
So we can just ignore exceptions with these three types?
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/jdbc/GravitinoJdbcCatalogFactory.java:
##########
@@ -51,13 +51,22 @@ public org.apache.flink.table.catalog.Catalog
createCatalog(Context context) {
Preconditions.checkArgument(
defaultDatabase != null,
GravitinoJdbcCatalogFactoryOptions.DEFAULT_DATABASE.key() + " should
not be null.");
- return new GravitinoJdbcCatalog(
+ return newCatalog(
context, defaultDatabase, schemaAndTablePropertiesConverter(),
partitionConverter());
}
+ protected Catalog newCatalog(
+ Context context,
+ String defaultDatabase,
+ SchemaAndTablePropertiesConverter schemaAndTablePropertiesConverter,
+ PartitionConverter partitionConverter) {
+ return new GravitinoJdbcCatalog(
+ context, defaultDatabase, schemaAndTablePropertiesConverter,
partitionConverter);
+ }
+
@Override
- public Catalog.Type gravitinoCatalogType() {
- return Catalog.Type.RELATIONAL;
+ public org.apache.gravitino.Catalog.Type gravitinoCatalogType() {
+ return org.apache.gravitino.Catalog.Type.RELATIONAL;
Review Comment:
org.apache.gravitino.Catalog
##########
flink-connector/v1.18/flink-runtime/build.gradle.kts:
##########
@@ -29,14 +29,8 @@ repositories {
mavenCentral()
}
-val flinkVersion: String = libs.versions.flink.get()
+val flinkVersion: String = libs.versions.flink18.get()
val flinkMajorVersion: String = flinkVersion.substringBeforeLast(".")
-
-// The Flink only support scala 2.12, and all scala api will be removed in a
future version.
-// You can find more detail at the following issues:
-// https://issues.apache.org/jira/browse/FLINK-23986,
-// https://issues.apache.org/jira/browse/FLINK-20845,
-// https://issues.apache.org/jira/browse/FLINK-13414.
Review Comment:
You may also remove them in `flink-common/build.gradle.kts`.
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/iceberg/GravitinoIcebergCatalog.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.flink.connector.iceberg;
+
+import java.util.Map;
+import java.util.Optional;
+import org.apache.flink.table.catalog.AbstractCatalog;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.factories.Factory;
+import org.apache.flink.util.Preconditions;
+import org.apache.gravitino.flink.connector.PartitionConverter;
+import org.apache.gravitino.flink.connector.SchemaAndTablePropertiesConverter;
+import org.apache.gravitino.flink.connector.catalog.BaseCatalog;
+import org.apache.iceberg.flink.FlinkCatalogFactory;
+
+/** Gravitino Iceberg Catalog. */
+public class GravitinoIcebergCatalog extends BaseCatalog {
+
+ private final AbstractCatalog icebergCatalog;
+
+ protected GravitinoIcebergCatalog(
+ String catalogName,
+ String defaultDatabase,
+ SchemaAndTablePropertiesConverter schemaAndTablePropertiesConverter,
+ PartitionConverter partitionConverter,
+ Map<String, String> catalogOptions,
+ Map<String, String> icebergCatalogProperties) {
+ super(
+ catalogName,
+ catalogOptions,
+ defaultDatabase,
+ schemaAndTablePropertiesConverter,
+ partitionConverter);
+ this.icebergCatalog =
+ requireAbstractCatalog(
+ new FlinkCatalogFactory().createCatalog(catalogName,
icebergCatalogProperties));
+ }
+
+ protected GravitinoIcebergCatalog(
+ String catalogName,
+ String defaultDatabase,
+ SchemaAndTablePropertiesConverter schemaAndTablePropertiesConverter,
+ PartitionConverter partitionConverter,
+ Map<String, String> catalogOptions,
+ AbstractCatalog icebergCatalog) {
+ super(
+ catalogName,
+ catalogOptions,
+ defaultDatabase,
+ schemaAndTablePropertiesConverter,
+ partitionConverter);
+ this.icebergCatalog = icebergCatalog;
+ }
+
+ @Override
+ public Optional<Factory> getFactory() {
+ return icebergCatalog.getFactory();
+ }
+
+ @Override
+ protected AbstractCatalog realCatalog() {
+ return icebergCatalog;
+ }
+
+ protected static AbstractCatalog requireAbstractCatalog(Catalog catalog) {
Review Comment:
Based on the method name, the return value should be a Boolean value. Can
you try to polish the name?
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/utils/CatalogCompat.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.flink.connector.utils;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.flink.table.api.Schema;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.ResolvedCatalogTable;
+
+/** Typed compatibility hook that is implemented per Flink minor version. */
+public interface CatalogCompat {
+
+ /**
+ * Create a {@link CatalogTable} using the Flink minor version's constructor
and behavior.
Review Comment:
I'm not very clear about `minor version's constructor and behavior`, why
only minor version?
##########
flink-connector/v1.18/flink/build.gradle.kts:
##########
@@ -0,0 +1,199 @@
+/*
+ * 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.
+ */
+import org.gradle.api.tasks.SourceSetContainer
+
+plugins {
+ `maven-publish`
+ id("java")
+ id("idea")
+}
+
+repositories {
+ mavenCentral()
+}
+
+val commonProject = project(":flink-connector:flink-common")
+val commonSourceSets = commonProject.extensions.getByType<SourceSetContainer>()
+val commonTestOutput = commonSourceSets.named("test").get().output
+val flinkVersion: String = libs.versions.flink18.get()
+val flinkMajorVersion: String = flinkVersion.substringBeforeLast(".")
+val icebergVersion: String = libs.versions.iceberg4flink18.get()
+val paimonVersion: String = libs.versions.paimon4flink18.get()
+val scalaVersion: String = "2.12"
+val artifactName =
"${rootProject.name}-flink-${flinkMajorVersion}_$scalaVersion"
+
+dependencies {
+ implementation(commonProject)
+
+ compileOnly(project(":clients:client-java-runtime", configuration =
"shadow"))
+
compileOnly("org.apache.iceberg:iceberg-flink-runtime-$flinkMajorVersion:$icebergVersion")
+
compileOnly("org.apache.flink:flink-connector-hive_$scalaVersion:$flinkVersion")
+ compileOnly("org.apache.flink:flink-table-common:$flinkVersion")
+ compileOnly("org.apache.flink:flink-table-api-java:$flinkVersion")
+
compileOnly("org.apache.paimon:paimon-flink-$flinkMajorVersion:$paimonVersion")
+ compileOnly(libs.flinkjdbc18)
+ compileOnly(libs.hive2.common) {
+ exclude("org.eclipse.jetty.aggregate", "jetty-all")
+ exclude("org.eclipse.jetty.orbit", "javax.servlet")
+ }
+
+ testImplementation(project(":api"))
+ testImplementation(project(":catalogs:catalog-jdbc-common")) {
+ exclude("org.apache.logging.log4j")
+ }
+ testImplementation(project(":clients:client-java"))
+ testImplementation(project(":core"))
+ testImplementation(project(":common"))
+ testImplementation(project(":integration-test-common", "testArtifacts"))
+ testImplementation(project(":server"))
+ testImplementation(project(":server-common"))
+ testImplementation(project(":flink-connector:flink-common", "testArtifacts"))
+ testImplementation(libs.awaitility)
+ testImplementation(libs.junit.jupiter.api)
+ testImplementation(libs.junit.jupiter.params)
+ testImplementation(libs.mockito.core)
+ testImplementation(libs.mysql.driver)
+ testImplementation(libs.postgresql.driver)
+ testImplementation(libs.sqlite.jdbc)
+ testImplementation(libs.testcontainers)
+ testImplementation(libs.testcontainers.junit.jupiter)
+ testImplementation(libs.testcontainers.mysql)
+ testImplementation(libs.metrics.core)
+ testImplementation(libs.flinkjdbc18)
+ testImplementation(libs.minikdc)
+
+ testImplementation("org.apache.iceberg:iceberg-core:$icebergVersion")
+
testImplementation("org.apache.iceberg:iceberg-hive-metastore:$icebergVersion")
+
testImplementation("org.apache.iceberg:iceberg-flink-runtime-$flinkMajorVersion:$icebergVersion")
+
testImplementation("org.apache.flink:flink-connector-hive_$scalaVersion:$flinkVersion")
+ testImplementation("org.apache.flink:flink-table-common:$flinkVersion")
+ testImplementation("org.apache.flink:flink-table-api-java:$flinkVersion")
+ testImplementation("org.apache.flink:flink-sql-gateway:$flinkVersion")
+
testImplementation("org.apache.paimon:paimon-flink-$flinkMajorVersion:$paimonVersion")
+
+ testImplementation(libs.hive2.exec) {
+ artifact {
+ classifier = "core"
+ }
+ exclude("com.fasterxml.jackson.core")
+ exclude("com.google.code.findbugs", "jsr305")
+ exclude("com.google.protobuf")
+ exclude("org.apache.avro")
+ exclude("org.apache.calcite")
+ exclude("org.apache.calcite.avatica")
+ exclude("org.apache.curator")
+ exclude("org.apache.hadoop", "hadoop-yarn-server-resourcemanager")
+ exclude("org.apache.logging.log4j")
+ exclude("org.apache.zookeeper")
+ exclude("org.eclipse.jetty.aggregate", "jetty-all")
+ exclude("org.eclipse.jetty.orbit", "javax.servlet")
+ exclude("org.openjdk.jol")
+ exclude("org.pentaho")
+ exclude("org.slf4j")
+ }
+
+ testImplementation(libs.hadoop2.common) {
+ exclude("*")
+ }
+ testImplementation(libs.hadoop2.hdfs) {
+ exclude("com.sun.jersey")
+ exclude("commons-cli", "commons-cli")
+ exclude("commons-io", "commons-io")
+ exclude("commons-codec", "commons-codec")
+ exclude("commons-logging", "commons-logging")
+ exclude("javax.servlet", "servlet-api")
+ exclude("org.mortbay.jetty")
+ }
+ testImplementation(libs.hadoop2.mapreduce.client.core) {
+ exclude("*")
+ }
+ testImplementation(libs.hive2.common) {
+ exclude("org.eclipse.jetty.aggregate", "jetty-all")
+ exclude("org.eclipse.jetty.orbit", "javax.servlet")
+ }
+ testImplementation(libs.hive2.metastore) {
+ exclude("co.cask.tephra")
+ exclude("com.github.joshelser")
+ exclude("com.google.code.findbugs", "jsr305")
+ exclude("com.google.code.findbugs", "sr305")
+ exclude("com.tdunning", "json")
+ exclude("com.zaxxer", "HikariCP")
+ exclude("io.dropwizard.metrics")
+ exclude("javax.transaction", "transaction-api")
+ exclude("org.apache.avro")
+ exclude("org.apache.curator")
+ exclude("org.apache.hbase")
+ exclude("org.apache.hadoop", "hadoop-yarn-server-resourcemanager")
+ exclude("org.apache.logging.log4j")
+ exclude("org.apache.parquet", "parquet-hadoop-bundle")
+ exclude("org.apache.zookeeper")
+ exclude("org.eclipse.jetty.aggregate", "jetty-all")
+ exclude("org.eclipse.jetty.orbit", "javax.servlet")
+ exclude("org.slf4j")
+ }
+
testImplementation("org.apache.flink:flink-table-api-bridge-base:$flinkVersion")
{
+ exclude("commons-cli", "commons-cli")
+ exclude("commons-io", "commons-io")
+ exclude("com.google.code.findbugs", "jsr305")
+ }
+
testImplementation("org.apache.flink:flink-table-planner_$scalaVersion:$flinkVersion")
+ testImplementation("org.apache.flink:flink-test-utils:$flinkVersion")
+
+ testRuntimeOnly(libs.junit.jupiter.engine)
+}
+
+tasks.test {
+ dependsOn(commonProject.tasks.named("testClasses"))
+ testClassesDirs = files(commonTestOutput.classesDirs,
sourceSets["test"].output.classesDirs)
+ classpath = files(commonTestOutput, sourceSets["test"].runtimeClasspath)
Review Comment:
Why don't we just introduce the dependence of `flink-common` test jars.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]