World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#6646] fix(iceberg): Delete the null value check for user and password in Iceberg JDBC catalog (#6691)
Xiaojian Sun9b0680cd4ac6
diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.javaindex 40e437a0f2..75a7a8be4a 100644--- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java+++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java@@ -53,8 +53,6 @@ public class TestMultipleJDBCLoad extends BaseIT {private static MySQLContainer mySQLContainer;private static PostgreSQLContainer postgreSQLContainer;- public static final String DEFAULT_POSTGRES_IMAGE = "postgres:13";-@BeforeAllpublic void startup() throws IOException {containerSuite.startMySQLContainer(TEST_DB_NAME);@@ -63,6 +61,36 @@ public class TestMultipleJDBCLoad extends BaseIT {postgreSQLContainer = containerSuite.getPostgreSQLContainer();}+ @Test+ public void testJdbcCatalogCreationWithUrlCredentials() throws Exception {+ String metalakeName = RandomNameUtils.genRandomName("it_metalake");+ GravitinoMetalake metalake =+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());++ Map<String, String> icebergMysqlConf = Maps.newHashMap();++ String jdbcUrl =+ mySQLContainer.getJdbcUrl(TEST_DB_NAME)+ + "?user="+ + mySQLContainer.getUsername()+ + "&password="+ + mySQLContainer.getPassword();++ icebergMysqlConf.put(IcebergConfig.CATALOG_URI.getKey(), jdbcUrl);+ icebergMysqlConf.put(IcebergConfig.CATALOG_BACKEND.getKey(), "jdbc");+ icebergMysqlConf.put(IcebergConfig.CATALOG_WAREHOUSE.getKey(), "file:///tmp/iceberg-jdbc");+ icebergMysqlConf.put(+ IcebergConfig.JDBC_DRIVER.getKey(), mySQLContainer.getDriverClassName(TEST_DB_NAME));+ String mysqlCatalogName = RandomNameUtils.genRandomName("it_iceberg_mysql");+ metalake.testConnection(+ mysqlCatalogName,+ Catalog.Type.RELATIONAL,+ "lakehouse-iceberg",+ "comment",+ icebergMysqlConf);+ Assertions.assertTrue(true);+ }+@Testpublic void testCreateMultipleJdbcInIceberg() throws URISyntaxException, SQLException {String metalakeName = RandomNameUtils.genRandomName("it_metalake");diff --git a/docs/iceberg-rest-service.md b/docs/iceberg-rest-service.mdindex 76d48b24e6..07ceeac782 100644--- a/docs/iceberg-rest-service.md+++ b/docs/iceberg-rest-service.md@@ -85,7 +85,7 @@ Gravitino Iceberg REST server supports OAuth2 and HTTPS, please refer to [Securi#### Backend authentication-For JDBC backend, you can use the `gravitino.iceberg-rest.jdbc.user` and `gravitino.iceberg-rest.jdbc.password` to authenticate the JDBC connection. For Hive backend, you can use the `gravitino.iceberg-rest.authentication.type` to specify the authentication type, and use the `gravitino.iceberg-rest.authentication.kerberos.principal` and `gravitino.iceberg-rest.authentication.kerberos.keytab-uri` to authenticate the Kerberos connection.+For JDBC backend, you can use the `gravitino.iceberg-rest.jdbc-user` and `gravitino.iceberg-rest.jdbc-password` to authenticate the JDBC connection. For Hive backend, you can use the `gravitino.iceberg-rest.authentication.type` to specify the authentication type, and use the `gravitino.iceberg-rest.authentication.kerberos.principal` and `gravitino.iceberg-rest.authentication.kerberos.keytab-uri` to authenticate the Kerberos connection.The detailed configuration items are as follows:| Configuration item | Description | Default value | Required | Since Version |@@ -141,7 +141,7 @@ Additionally, Iceberg doesn't provide Iceberg Aliyun bundle jar which contains OPlease place the above jars in the classpath of Iceberg REST server, please refer to [server management](#server-management) for classpath details.:::info-Please set the `gravitino.iceberg-rest.warehouse` parameter to `oss://{bucket_name}/${prefix_name}`.+Please set the `gravitino.iceberg-rest.warehouse` parameter to `oss://{bucket_name}/${prefix_name}`.:::#### GCS@@ -217,16 +217,16 @@ The Gravitino Iceberg REST catalog service uses the memory catalog backend by de#### JDBC backend configuration-| Configuration item | Description | Default value | Required | Since Version |-|---------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------|----------|---------------|-| `gravitino.iceberg-rest.catalog-backend` | The Catalog backend of the Gravitino Iceberg REST catalog service. Use the value **`jdbc`** for a JDBC catalog. | `memory` | Yes | 0.2.0 |-| `gravitino.iceberg-rest.uri` | The JDBC connection address, such as `jdbc:postgresql://127.0.0.1:5432` for Postgres, or `jdbc:mysql://127.0.0.1:3306/` for mysql. | (none) | Yes | 0.2.0 |-| `gravitino.iceberg-rest.warehouse ` | The warehouse directory of JDBC catalog. Set the HDFS prefix if using HDFS, such as `hdfs://127.0.0.1:9000/user/hive/warehouse-jdbc` | (none) | Yes | 0.2.0 |-| `gravitino.iceberg-rest.catalog-backend-name` | The catalog name passed to underlying Iceberg catalog backend. Catalog name in JDBC backend is used to isolate namespace and tables. | `jdbc` for JDBC backend | No | 0.5.2 |-| `gravitino.iceberg-rest.jdbc.user` | The username of the JDBC connection. | (none) | Yes | 0.2.0 |-| `gravitino.iceberg-rest.jdbc.password` | The password of the JDBC connection. | (none) | Yes | 0.2.0 |-| `gravitino.iceberg-rest.jdbc-initialize` | Whether to initialize the meta tables when creating the JDBC catalog. | `true` | No | 0.2.0 |-| `gravitino.iceberg-rest.jdbc-driver` | `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver` for MySQL, `org.postgresql.Driver` for PostgreSQL. | (none) | Yes | 0.3.0 |+| Configuration item | Description | Default value | Required | Since Version |+|-----------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------|----------|---------------|+| `gravitino.iceberg-rest.catalog-backend` | The Catalog backend of the Gravitino Iceberg REST catalog service. Use the value **`jdbc`** for a JDBC catalog. | `memory` | Yes | 0.2.0 |+| `gravitino.iceberg-rest.uri` | The JDBC connection address, such as `jdbc:postgresql://127.0.0.1:5432` for Postgres, or `jdbc:mysql://127.0.0.1:3306/` for mysql. | (none) | Yes | 0.2.0 |+| `gravitino.iceberg-rest.warehouse ` | The warehouse directory of JDBC catalog. Set the HDFS prefix if using HDFS, such as `hdfs://127.0.0.1:9000/user/hive/warehouse-jdbc` | (none) | Yes | 0.2.0 |+| `gravitino.iceberg-rest.catalog-backend-name` | The catalog name passed to underlying Iceberg catalog backend. Catalog name in JDBC backend is used to isolate namespace and tables. | `jdbc` for JDBC backend | No | 0.5.2 |+| `gravitino.iceberg-rest.jdbc-user` | The username of the JDBC connection. | (none) | No | 0.2.0 |+| `gravitino.iceberg-rest.jdbc-password` | The password of the JDBC connection. | (none) | No | 0.2.0 |+| `gravitino.iceberg-rest.jdbc-initialize` | Whether to initialize the meta tables when creating the JDBC catalog. | `true` | No | 0.2.0 |+| `gravitino.iceberg-rest.jdbc-driver` | `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver` for MySQL, `org.postgresql.Driver` for PostgreSQL. | (none) | Yes | 0.3.0 |If you have a JDBC Iceberg catalog prior, you must set `catalog-backend-name` to keep consistent with your Jdbc Iceberg catalog name to operate the prior namespace and tables.@@ -468,3 +468,4 @@ sh ./dev/docker/build-docker.sh --platform linux/arm64 --type iceberg-rest-serve```You could try Spark with Gravitino REST catalog service in our [playground](./how-to-use-the-playground.md#using-apache-iceberg-rest-service).+diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.javaindex 77f8b9a22b..fe33948606 100644--- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java+++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java@@ -22,7 +22,6 @@ import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITYimport static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION;import com.google.common.annotations.VisibleForTesting;-import com.google.common.base.Preconditions;import java.io.File;import java.io.IOException;import java.sql.SQLException;@@ -123,12 +122,6 @@ public class IcebergCatalogUtil {String icebergCatalogName = icebergConfig.getCatalogBackendName();Map<String, String> properties = icebergConfig.getIcebergCatalogProperties();- Preconditions.checkNotNull(- properties.get(IcebergConstants.ICEBERG_JDBC_USER),- IcebergConstants.ICEBERG_JDBC_USER + " is null");- Preconditions.checkNotNull(- properties.get(IcebergConstants.ICEBERG_JDBC_PASSWORD),- IcebergConstants.ICEBERG_JDBC_PASSWORD + " is null");try {// Load the jdbc driverClass.forName(driverClassName);