This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b5fe79f8298 [fix](iceberg) Decouple JDBC catalog metadata name (#62806)
b5fe79f8298 is described below
commit b5fe79f82989b4c2328f298acb00becd7fd794e2
Author: Socrates <[email protected]>
AuthorDate: Sun Apr 26 23:18:03 2026 +0800
[fix](iceberg) Decouple JDBC catalog metadata name (#62806)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #59502
Problem Summary:
Doris initialized Iceberg JDBC Catalog with the Doris local catalog
name. Iceberg JDBC Catalog uses the SDK catalog initialization name as
the `catalog_name` isolation key in JDBC metadata tables, so a Doris
catalog named differently from the writer catalog, such as Spark
`spark_catalog`, could not list namespaces or tables written under that
remote `catalog_name`.
This PR adds required `iceberg.jdbc.catalog_name` for Iceberg JDBC
catalog and uses it as the Iceberg SDK catalog initialization name. The
Doris local catalog name remains independent and continues to be used
for Doris namespace/table identifier semantics.
---
.../metastore/IcebergJdbcMetaStoreProperties.java | 10 ++-
.../IcebergJdbcMetaStorePropertiesTest.java | 72 ++++++++++++++++++++++
.../iceberg/test_iceberg_jdbc_catalog.groovy | 8 ++-
3 files changed, 87 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStoreProperties.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStoreProperties.java
index ea2cb0c5836..6be4b31dc2d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStoreProperties.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStoreProperties.java
@@ -90,6 +90,13 @@ public class IcebergJdbcMetaStoreProperties extends
AbstractIcebergProperties {
)
private String jdbcStrictMode;
+ @ConnectorProperty(
+ names = {"iceberg.jdbc.catalog_name"},
+ required = true,
+ description = "The Iceberg JDBC catalog_name used to isolate
metadata in JDBC catalog tables."
+ )
+ private String jdbcCatalogName;
+
@ConnectorProperty(
names = {"iceberg.jdbc.driver_url"},
required = false,
@@ -142,7 +149,8 @@ public class IcebergJdbcMetaStoreProperties extends
AbstractIcebergProperties {
registerJdbcDriver(driverUrl, driverClass);
LOG.info("Using dynamic JDBC driver from: {}", driverUrl);
}
- return buildIcebergCatalog(catalogName, catalogProps, configuration);
+ catalogProps.remove("iceberg.jdbc.catalog_name");
+ return buildIcebergCatalog(jdbcCatalogName, catalogProps,
configuration);
}
/**
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStorePropertiesTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStorePropertiesTest.java
index 25b7f3ecdda..07977a17615 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStorePropertiesTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/IcebergJdbcMetaStorePropertiesTest.java
@@ -17,16 +17,44 @@
package org.apache.doris.datasource.property.metastore;
+import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.CatalogUtil;
+import org.apache.iceberg.catalog.Catalog;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class IcebergJdbcMetaStorePropertiesTest {
+ private static class CapturingIcebergJdbcMetaStoreProperties extends
IcebergJdbcMetaStoreProperties {
+ private String capturedCatalogName;
+ private Map<String, String> capturedOptions;
+
+ CapturingIcebergJdbcMetaStoreProperties(Map<String, String> props) {
+ super(props);
+ }
+
+ @Override
+ protected Catalog buildIcebergCatalog(String catalogName, Map<String,
String> options, Configuration conf) {
+ capturedCatalogName = catalogName;
+ capturedOptions = new HashMap<>(options);
+ return Mockito.mock(Catalog.class);
+ }
+
+ String getCapturedCatalogName() {
+ return capturedCatalogName;
+ }
+
+ Map<String, String> getCapturedOptions() {
+ return capturedOptions;
+ }
+ }
+
@Test
public void testBasicJdbcProperties() {
Map<String, String> props = new HashMap<>();
@@ -34,6 +62,7 @@ public class IcebergJdbcMetaStorePropertiesTest {
props.put("warehouse", "s3://warehouse/path");
props.put("jdbc.user", "iceberg");
props.put("jdbc.password", "secret");
+ props.put("iceberg.jdbc.catalog_name", "iceberg_catalog");
IcebergJdbcMetaStoreProperties jdbcProps = new
IcebergJdbcMetaStoreProperties(props);
jdbcProps.initNormalizeAndCheckProps();
@@ -53,6 +82,7 @@ public class IcebergJdbcMetaStorePropertiesTest {
props.put("warehouse", "s3://warehouse/path");
props.put("jdbc.useSSL", "true");
props.put("jdbc.verifyServerCertificate", "true");
+ props.put("iceberg.jdbc.catalog_name", "iceberg_catalog");
IcebergJdbcMetaStoreProperties jdbcProps = new
IcebergJdbcMetaStoreProperties(props);
jdbcProps.initNormalizeAndCheckProps();
@@ -79,4 +109,46 @@ public class IcebergJdbcMetaStorePropertiesTest {
IcebergJdbcMetaStoreProperties jdbcProps = new
IcebergJdbcMetaStoreProperties(props);
Assertions.assertThrows(IllegalArgumentException.class,
jdbcProps::initNormalizeAndCheckProps);
}
+
+ @Test
+ public void testJdbcCatalogNameOverridesSdkCatalogName() {
+ Map<String, String> props = createBaseProps();
+ props.put("iceberg.jdbc.catalog_name", "spark_catalog");
+
+ CapturingIcebergJdbcMetaStoreProperties jdbcProps = new
CapturingIcebergJdbcMetaStoreProperties(props);
+ jdbcProps.initNormalizeAndCheckProps();
+ jdbcProps.initializeCatalog("doris_catalog", Collections.emptyList());
+
+ Assertions.assertEquals("spark_catalog",
jdbcProps.getCapturedCatalogName());
+
Assertions.assertFalse(jdbcProps.getCapturedOptions().containsKey("iceberg.jdbc.catalog_name"));
+ }
+
+ @Test
+ public void testMissingJdbcCatalogNameThrowsException() {
+ CapturingIcebergJdbcMetaStoreProperties jdbcProps =
+ new CapturingIcebergJdbcMetaStoreProperties(createBaseProps());
+
+ IllegalArgumentException exception = Assertions.assertThrows(
+ IllegalArgumentException.class,
jdbcProps::initNormalizeAndCheckProps);
+ Assertions.assertEquals("Property iceberg.jdbc.catalog_name is
required.", exception.getMessage());
+ }
+
+ @Test
+ public void testBlankJdbcCatalogNameThrowsException() {
+ Map<String, String> props = createBaseProps();
+ props.put("iceberg.jdbc.catalog_name", " ");
+
+ CapturingIcebergJdbcMetaStoreProperties jdbcProps = new
CapturingIcebergJdbcMetaStoreProperties(props);
+
+ IllegalArgumentException exception = Assertions.assertThrows(
+ IllegalArgumentException.class,
jdbcProps::initNormalizeAndCheckProps);
+ Assertions.assertEquals("Property iceberg.jdbc.catalog_name is
required.", exception.getMessage());
+ }
+
+ private static Map<String, String> createBaseProps() {
+ Map<String, String> props = new HashMap<>();
+ props.put("uri", "jdbc:mysql://localhost:3306/iceberg");
+ props.put("warehouse", "s3://warehouse/path");
+ return props;
+ }
}
diff --git
a/regression-test/suites/external_table_p0/iceberg/test_iceberg_jdbc_catalog.groovy
b/regression-test/suites/external_table_p0/iceberg/test_iceberg_jdbc_catalog.groovy
index 257aa6bcaf3..11c887d25ce 100644
---
a/regression-test/suites/external_table_p0/iceberg/test_iceberg_jdbc_catalog.groovy
+++
b/regression-test/suites/external_table_p0/iceberg/test_iceberg_jdbc_catalog.groovy
@@ -45,7 +45,8 @@ suite("test_iceberg_jdbc_catalog", "p0,external") {
return;
}
- String catalog_name = "test_iceberg_jdbc_catalog"
+ String catalog_name = "test_iceberg_jdbc_catalog_doris"
+ String iceberg_jdbc_catalog_name = "test_iceberg_jdbc_catalog"
String db_name = "jdbc_test_db"
String driver_name = "postgresql-42.5.0.jar"
String driver_download_url =
"${getS3Url()}/regression/jdbc_driver/${driver_name}"
@@ -116,6 +117,7 @@ suite("test_iceberg_jdbc_catalog", "p0,external") {
'iceberg.jdbc.driver_class' = 'org.postgresql.Driver',
'iceberg.jdbc.user' = 'postgres',
'iceberg.jdbc.password' = '123456',
+ 'iceberg.jdbc.catalog_name' = '${iceberg_jdbc_catalog_name}',
'iceberg.jdbc.init-catalog-tables' = 'true',
'iceberg.jdbc.schema-version' = 'V1',
's3.endpoint' = 'http://${externalEnvIp}:${minio_port}',
@@ -237,7 +239,8 @@ suite("test_iceberg_jdbc_catalog", "p0,external") {
String cleanupCmd = "mysql -h ${externalEnvIp} -P ${mysql_port} -u
root -p123456 -e 'DROP DATABASE IF EXISTS iceberg_db; CREATE DATABASE
iceberg_db;'"
executeCommand(cleanupCmd, false)
- String mysql_catalog_name = "iceberg_jdbc_mysql"
+ String mysql_catalog_name = "iceberg_jdbc_mysql_doris"
+ String iceberg_jdbc_mysql_catalog_name = "iceberg_jdbc_mysql"
try {
sql """DROP CATALOG IF EXISTS ${mysql_catalog_name}"""
sql """
@@ -250,6 +253,7 @@ suite("test_iceberg_jdbc_catalog", "p0,external") {
'iceberg.jdbc.driver_class' = 'com.mysql.jdbc.Driver',
'iceberg.jdbc.user' = 'root',
'iceberg.jdbc.password' = '123456',
+ 'iceberg.jdbc.catalog_name' =
'${iceberg_jdbc_mysql_catalog_name}',
'iceberg.jdbc.init-catalog-tables' = 'true',
'iceberg.jdbc.schema-version' = 'V1',
's3.endpoint' =
'http://${externalEnvIp}:${minio_port}',
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]