This is an automated email from the ASF dual-hosted git repository.
etudenhoefner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new c02ebe4740 Core: Set missing table-default property in
RESTSessionCatalog (#11646)
c02ebe4740 is described below
commit c02ebe4740b22d6f5a78b636aea2d918037b2751
Author: Yuya Ebihara <[email protected]>
AuthorDate: Fri Mar 14 19:20:33 2025 +0900
Core: Set missing table-default property in RESTSessionCatalog (#11646)
---
.../apache/iceberg/rest/RESTSessionCatalog.java | 17 +++++++++++++-
.../org/apache/iceberg/catalog/CatalogTests.java | 26 ++++++++++++++++++++++
.../iceberg/inmemory/TestInMemoryCatalog.java | 11 ++++++++-
.../org/apache/iceberg/jdbc/TestJdbcCatalog.java | 2 ++
.../iceberg/jdbc/TestJdbcCatalogWithV1Schema.java | 2 ++
.../org/apache/iceberg/rest/TestRESTCatalog.java | 4 ++++
.../org/apache/iceberg/hive/TestHiveCatalog.java | 6 ++++-
.../apache/iceberg/nessie/TestNessieCatalog.java | 6 ++++-
.../java/org/apache/iceberg/rest/RCKUtils.java | 4 ++++
9 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
index 32fb400804..e3badfccdc 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
@@ -797,6 +797,21 @@ public class RESTSessionCatalog extends
BaseViewSessionCatalog
this.ident = ident;
this.schema = schema;
this.context = context;
+ propertiesBuilder.putAll(tableDefaultProperties());
+ }
+
+ /**
+ * Get default table properties set at Catalog level through catalog
properties.
+ *
+ * @return default table properties specified in catalog properties
+ */
+ private Map<String, String> tableDefaultProperties() {
+ Map<String, String> tableDefaultProperties =
+ PropertyUtil.propertiesWithPrefix(properties(),
CatalogProperties.TABLE_DEFAULT_PREFIX);
+ LOG.info(
+ "Table properties set at catalog level through catalog properties:
{}",
+ tableDefaultProperties);
+ return tableDefaultProperties;
}
@Override
@@ -841,7 +856,7 @@ public class RESTSessionCatalog extends
BaseViewSessionCatalog
.withPartitionSpec(spec)
.withWriteOrder(writeOrder)
.withLocation(location)
- .setProperties(propertiesBuilder.build())
+ .setProperties(propertiesBuilder.buildKeepingLast())
.build();
LoadTableResponse response =
diff --git a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
index b7cfd9b16b..a8afcc83c6 100644
--- a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
+++ b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
@@ -658,6 +658,32 @@ public abstract class CatalogTests<C extends Catalog &
SupportsNamespaces> {
.isEqualTo(UUID.fromString(((BaseTable)
table).operations().current().uuid()));
}
+ @Test
+ public void testDefaultTableProperties() {
+ C catalog = catalog();
+
+ TableIdentifier ident = TableIdentifier.of("ns", "table");
+
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(ident.namespace());
+ }
+
+ assertThat(catalog.tableExists(ident)).as("Table should not
exist").isFalse();
+
+ Table table =
+ catalog()
+ .buildTable(ident, SCHEMA)
+ .withProperty("default-key2", "catalog-overridden-key2")
+ .withProperty("prop1", "val1")
+ .create();
+ assertThat(table.properties())
+ .containsEntry("default-key1", "catalog-default-key1")
+ .containsEntry("default-key2", "catalog-overridden-key2")
+ .containsEntry("prop1", "val1");
+
+ assertThat(catalog.dropTable(ident)).as("Should successfully drop
table").isTrue();
+ }
+
@Test
public void testLoadTable() {
C catalog = catalog();
diff --git
a/core/src/test/java/org/apache/iceberg/inmemory/TestInMemoryCatalog.java
b/core/src/test/java/org/apache/iceberg/inmemory/TestInMemoryCatalog.java
index 6386e3189f..a9c371b0a1 100644
--- a/core/src/test/java/org/apache/iceberg/inmemory/TestInMemoryCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/inmemory/TestInMemoryCatalog.java
@@ -19,6 +19,7 @@
package org.apache.iceberg.inmemory;
import java.util.Map;
+import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.catalog.CatalogTests;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.BeforeEach;
@@ -28,7 +29,15 @@ public class TestInMemoryCatalog extends
CatalogTests<InMemoryCatalog> {
@BeforeEach
public void before() {
- this.catalog = initCatalog("in-memory-catalog", ImmutableMap.of());
+ this.catalog =
+ initCatalog(
+ "in-memory-catalog",
+ ImmutableMap.<String, String>builder()
+ .put(
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
"catalog-default-key1")
+ .put(
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
"catalog-default-key2")
+ .buildOrThrow());
}
@Override
diff --git a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
index 132d36cdab..0b146987ea 100644
--- a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
@@ -150,6 +150,8 @@ public class TestJdbcCatalog extends
CatalogTests<JdbcCatalog> {
properties.put(JdbcCatalog.PROPERTY_PREFIX + "password", "password");
warehouseLocation = this.tableDir.toAbsolutePath().toString();
properties.put(CatalogProperties.WAREHOUSE_LOCATION, warehouseLocation);
+ properties.put(CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
"catalog-default-key1");
+ properties.put(CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
"catalog-default-key2");
properties.put("type", "jdbc");
properties.putAll(additionalProperties);
diff --git
a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
index 74e3d6bc52..da284ff0fd 100644
---
a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
+++
b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
@@ -48,6 +48,8 @@ public class TestJdbcCatalogWithV1Schema extends
CatalogTests<JdbcCatalog> {
properties.put(JdbcCatalog.PROPERTY_PREFIX + "username", "user");
properties.put(JdbcCatalog.PROPERTY_PREFIX + "password", "password");
properties.put(CatalogProperties.WAREHOUSE_LOCATION,
tableDir.toAbsolutePath().toString());
+ properties.put(CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
"catalog-default-key1");
+ properties.put(CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
"catalog-default-key2");
properties.put(JdbcUtil.SCHEMA_VERSION_PROPERTY,
JdbcUtil.SchemaVersion.V1.name());
properties.putAll(additionalProperties);
diff --git a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
index 0455e2cf0d..28258b40cf 100644
--- a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
@@ -183,6 +183,10 @@ public class TestRESTCatalog extends
CatalogTests<RESTCatalog> {
httpServer.getURI().toString(),
CatalogProperties.FILE_IO_IMPL,
"org.apache.iceberg.inmemory.InMemoryFileIO",
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
+ "catalog-default-key1",
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
+ "catalog-default-key2",
"credential",
"catalog:12345");
catalog.initialize(
diff --git
a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
index 709bb1caaa..715f408dc4 100644
--- a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
+++ b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
@@ -121,7 +121,11 @@ public class TestHiveCatalog extends
CatalogTests<HiveCatalog> {
Map<String, String> properties =
ImmutableMap.of(
CatalogProperties.CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS,
- String.valueOf(TimeUnit.SECONDS.toMillis(10)));
+ String.valueOf(TimeUnit.SECONDS.toMillis(10)),
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
+ "catalog-default-key1",
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
+ "catalog-default-key2");
return (HiveCatalog)
CatalogUtil.loadCatalog(
diff --git
a/nessie/src/test/java/org/apache/iceberg/nessie/TestNessieCatalog.java
b/nessie/src/test/java/org/apache/iceberg/nessie/TestNessieCatalog.java
index dce8f7ff0f..6efa57df5f 100644
--- a/nessie/src/test/java/org/apache/iceberg/nessie/TestNessieCatalog.java
+++ b/nessie/src/test/java/org/apache/iceberg/nessie/TestNessieCatalog.java
@@ -124,7 +124,11 @@ public class TestNessieCatalog extends
CatalogTests<NessieCatalog> {
CatalogProperties.URI,
uri,
CatalogProperties.WAREHOUSE_LOCATION,
- temp.toUri().toString());
+ temp.toUri().toString(),
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
+ "catalog-default-key1",
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
+ "catalog-default-key2");
return (NessieCatalog)
CatalogUtil.buildIcebergCatalog(
diff --git
a/open-api/src/testFixtures/java/org/apache/iceberg/rest/RCKUtils.java
b/open-api/src/testFixtures/java/org/apache/iceberg/rest/RCKUtils.java
index 23e53da217..5e5d04645d 100644
--- a/open-api/src/testFixtures/java/org/apache/iceberg/rest/RCKUtils.java
+++ b/open-api/src/testFixtures/java/org/apache/iceberg/rest/RCKUtils.java
@@ -96,6 +96,10 @@ class RCKUtils {
catalogProperties.putIfAbsent(
CatalogProperties.URI, String.format("http://localhost:%s/", port));
catalogProperties.putIfAbsent(CatalogProperties.WAREHOUSE_LOCATION,
"rck_warehouse");
+ catalogProperties.putIfAbsent(
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key1",
"catalog-default-key1");
+ catalogProperties.putIfAbsent(
+ CatalogProperties.TABLE_DEFAULT_PREFIX + "default-key2",
"catalog-default-key2");
catalogProperties.putIfAbsent(
CatalogProperties.VIEW_DEFAULT_PREFIX + "key1",
"catalog-default-key1");
catalogProperties.putIfAbsent(