This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 005bbd874c [#7395] fix(iceberg): add default catalog for dynamic
config proivder for IRC (#8327)
005bbd874c is described below
commit 005bbd874c4203c3a982096f68c017f825bb4799
Author: FANNG <[email protected]>
AuthorDate: Tue Sep 2 12:05:32 2025 +0900
[#7395] fix(iceberg): add default catalog for dynamic config proivder for
IRC (#8327)
### What changes were proposed in this pull request?
add default catalog for dynamic config proivder
### Why are the changes needed?
Fix: #7395
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
test in local env, after setting `default-catalog-name`, the Spark
Iceberg side doesn't need to specify `warehouse`
---
.../lakehouse/iceberg/IcebergConstants.java | 1 +
docs/iceberg-rest-service.md | 11 ++++++-----
.../provider/DynamicIcebergConfigProvider.java | 22 ++++++++++++++++++----
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git
a/catalogs/catalog-common/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergConstants.java
b/catalogs/catalog-common/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergConstants.java
index b41e8bf694..d4fd8baad4 100644
---
a/catalogs/catalog-common/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergConstants.java
+++
b/catalogs/catalog-common/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergConstants.java
@@ -92,4 +92,5 @@ public class IcebergConstants {
public static final String ICEBERG_REST_DEFAULT_METALAKE = "gravitino";
public static final String ICEBERG_REST_DEFAULT_CATALOG = "default_catalog";
+ public static final String ICEBERG_REST_DEFAULT_DYNAMIC_CATALOG_NAME =
"default-catalog-name";
}
diff --git a/docs/iceberg-rest-service.md b/docs/iceberg-rest-service.md
index bfe220af03..5241681500 100644
--- a/docs/iceberg-rest-service.md
+++ b/docs/iceberg-rest-service.md
@@ -168,11 +168,12 @@ gravitino.iceberg-rest.catalog.jdbc_backend.warehouse =
hdfs://127.0.0.1:9000/us
The dynamic catalog configuration provider retrieves the catalog configuration
from the Gravitino server, and the catalog configuration could be updated
dynamically.
-| Configuration item | Description
| Default value |
Required | Since Version |
-|-------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|
-| `gravitino.iceberg-rest.gravitino-uri` | The uri of
Gravitino server address, only worked if `catalog-config-provider` is
`dynamic-config-provider`. | (none)
| No | 0.7.0-incubating |
-| `gravitino.iceberg-rest.gravitino-metalake` | The metalake
name that `dynamic-config-provider` used to request to Gravitino, only worked
if `catalog-config-provider` is `dynamic-config-provider`. | (none) | No
| 0.7.0-incubating |
-| `gravitino.iceberg-rest.catalog-cache-eviction-interval-ms` | Catalog cache
eviction interval.
| 3600000 | No
| 0.7.0-incubating |
+| Configuration item | Description
| Default value | Required | Since Version |
+|-------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|
+| `gravitino.iceberg-rest.gravitino-uri` | The uri of
Gravitino server address, only worked if `catalog-config-provider` is
`dynamic-config-provider`.
| (none) | No |
0.7.0-incubating |
+| `gravitino.iceberg-rest.gravitino-metalake` | The metalake
name that `dynamic-config-provider` used to request to Gravitino, only worked
if `catalog-config-provider` is `dynamic-config-provider`.
| (none) | No | 0.7.0-incubating |
+| `gravitino.iceberg-rest.default-catalog-name` | The default
catalog name used by Iceberg REST server if the Iceberg REST client doesn't
specify the catalog name explicitly. Only worked if `catalog-config-provider`
is `dynamic-config-provider`. | (none) | No | 1.0.0 |
+| `gravitino.iceberg-rest.catalog-cache-eviction-interval-ms` | Catalog cache
eviction interval.
| 3600000 | No | 0.7.0-incubating |
```text
gravitino.iceberg-rest.catalog-cache-eviction-interval-ms = 300000
diff --git
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java
index 4d1ea76596..cda000aeab 100644
---
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java
+++
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/provider/DynamicIcebergConfigProvider.java
@@ -45,8 +45,10 @@ import org.apache.gravitino.utils.MapUtils;
* <p>The catalogName is iceberg_catalog
*/
public class DynamicIcebergConfigProvider implements IcebergConfigProvider {
+
private String gravitinoMetalake;
private String gravitinoUri;
+ private Optional<String> defaultDynamicCatalogName;
private Map<String, String> properties;
private volatile GravitinoClient client;
@@ -63,6 +65,9 @@ public class DynamicIcebergConfigProvider implements
IcebergConfigProvider {
this.gravitinoMetalake = metalake;
this.gravitinoUri = uri;
+ this.defaultDynamicCatalogName =
+ Optional.ofNullable(
+
properties.get(IcebergConstants.ICEBERG_REST_DEFAULT_DYNAMIC_CATALOG_NAME));
this.properties = properties;
}
@@ -70,10 +75,19 @@ public class DynamicIcebergConfigProvider implements
IcebergConfigProvider {
public Optional<IcebergConfig> getIcebergCatalogConfig(String catalogName) {
Preconditions.checkArgument(
StringUtils.isNotBlank(catalogName), "blank catalogName is illegal");
- Preconditions.checkArgument(
- !IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG.equals(catalogName),
- IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG + " is illegal in
gravitino-based-provider");
-
+ if (catalogName.equals(IcebergConstants.ICEBERG_REST_DEFAULT_CATALOG)) {
+ catalogName =
+ defaultDynamicCatalogName.orElseThrow(
+ () ->
+ new IllegalArgumentException(
+ String.format(
+ "For dynamic config provider, Please use `%s` in
iceberg client side to specify "
+ + "the catalog name or setting `%s` in REST
server side to specify the "
+ + "default catalog name.",
+ IcebergConstants.WAREHOUSE,
+ IcebergConfig.ICEBERG_CONFIG_PREFIX
+ +
IcebergConstants.ICEBERG_REST_DEFAULT_DYNAMIC_CATALOG_NAME)));
+ }
Catalog catalog;
try {
catalog =
getGravitinoClient().loadMetalake(gravitinoMetalake).loadCatalog(catalogName);