diff --git a/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonTablePropertiesMetadata.java b/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonTablePropertiesMetadata.java index 1c57e5b2cc5..5fb34605554 100644 --- a/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonTablePropertiesMetadata.java +++ b/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonTablePropertiesMetadata.java @@ -18,6 +18,7 @@ */ package org.apache.gravitino.catalog.lakehouse.paimon; +import static org.apache.gravitino.connector.PropertyEntry.stringImmutablePropertyEntry; import static org.apache.gravitino.connector.PropertyEntry.stringReservedPropertyEntry; import com.google.common.collect.ImmutableList; @@ -50,12 +51,18 @@ public class PaimonTablePropertiesMetadata extends BasePropertiesMetadata { ImmutableList.of( stringReservedPropertyEntry(COMMENT, "The table comment", true), stringReservedPropertyEntry(OWNER, "The table owner", false), - stringReservedPropertyEntry(BUCKET_KEY, "The table bucket key", false), - stringReservedPropertyEntry(MERGE_ENGINE, "The table merge engine", false), - stringReservedPropertyEntry(SEQUENCE_FIELD, "The table sequence field", false), - stringReservedPropertyEntry(ROWKIND_FIELD, "The table rowkind field", false), - stringReservedPropertyEntry(PRIMARY_KEY, "The table primary key", false), - stringReservedPropertyEntry(PARTITION, "The table partition", false)); + stringImmutablePropertyEntry( + BUCKET_KEY, "The table bucket key", false, null, false, false), + stringImmutablePropertyEntry( + MERGE_ENGINE, "The table merge engine", false, null, false, false), + stringImmutablePropertyEntry( + SEQUENCE_FIELD, "The table sequence field", false, null, false, false), + stringImmutablePropertyEntry( + ROWKIND_FIELD, "The table rowkind field", false, null, false, false), + stringImmutablePropertyEntry( + PRIMARY_KEY, "The table primary key", false, null, false, false), + stringImmutablePropertyEntry( + PARTITION, "The table partition", false, null, false, false)); PROPERTIES_METADATA = Maps.uniqueIndex(propertyEntries, PropertyEntry::getName); } diff --git a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/TestGravitinoPaimonTable.java b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/TestGravitinoPaimonTable.java index 05e36219d99..13b0aab6692 100644 --- a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/TestGravitinoPaimonTable.java +++ b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/TestGravitinoPaimonTable.java @@ -382,29 +382,30 @@ void testTableProperty() { try (PaimonCatalogOperations ops = new PaimonCatalogOperations()) { ops.initialize( initBackendCatalogProperties(), entity.toCatalogInfo(), PAIMON_PROPERTIES_METADATA); - Map map = Maps.newHashMap(); - map.put(PaimonTablePropertiesMetadata.COMMENT, "test"); - map.put(PaimonTablePropertiesMetadata.OWNER, "test"); - map.put(PaimonTablePropertiesMetadata.BUCKET_KEY, "test"); - map.put(PaimonTablePropertiesMetadata.MERGE_ENGINE, "test"); - map.put(PaimonTablePropertiesMetadata.SEQUENCE_FIELD, "test"); - map.put(PaimonTablePropertiesMetadata.ROWKIND_FIELD, "test"); - map.put(PaimonTablePropertiesMetadata.PRIMARY_KEY, "test"); - map.put(PaimonTablePropertiesMetadata.PARTITION, "test"); - for (Map.Entry entry : map.entrySet()) { - HashMap properties = - new HashMap() { - { - put(entry.getKey(), entry.getValue()); - } - }; - PropertiesMetadata metadata = paimonCatalog.tablePropertiesMetadata(); - Assertions.assertThrows( - IllegalArgumentException.class, - () -> PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties)); - } - - map = Maps.newHashMap(); + HashMap properties1 = + new HashMap() { + { + put(PaimonTablePropertiesMetadata.COMMENT, "test"); + put(PaimonTablePropertiesMetadata.OWNER, "test"); + } + }; + Assertions.assertThrows( + IllegalArgumentException.class, + () -> + PropertiesMetadataHelpers.validatePropertyForCreate( + paimonCatalog.tablePropertiesMetadata(), properties1)); + Assertions.assertThrows( + IllegalArgumentException.class, + () -> + PropertiesMetadataHelpers.validatePropertyForAlter( + paimonCatalog.tablePropertiesMetadata(), properties1, Collections.emptyMap())); + Assertions.assertThrows( + IllegalArgumentException.class, + () -> + PropertiesMetadataHelpers.validatePropertyForAlter( + paimonCatalog.tablePropertiesMetadata(), Collections.emptyMap(), properties1)); + + Map map = Maps.newHashMap(getStringImmutableProperties()); map.put("key1", "val1"); map.put("key2", "val2"); for (Map.Entry entry : map.entrySet()) { @@ -416,9 +417,15 @@ void testTableProperty() { }; PropertiesMetadata metadata = paimonCatalog.tablePropertiesMetadata(); Assertions.assertDoesNotThrow( - () -> { - PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties); - }); + () -> PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties)); + Assertions.assertDoesNotThrow( + () -> + PropertiesMetadataHelpers.validatePropertyForAlter( + metadata, properties, Collections.emptyMap())); + Assertions.assertDoesNotThrow( + () -> + PropertiesMetadataHelpers.validatePropertyForAlter( + metadata, Collections.emptyMap(), properties)); } } } @@ -624,4 +631,19 @@ private static Column[] createColumns() { "col3", Types.StringType.get(), "col_3_comment", false, false, DEFAULT_VALUE_NOT_SET); return new Column[] {col1, col2, col3}; } + + private static Map getStringImmutableProperties() { + Map map = Maps.newHashMap(); + map.put(PaimonTablePropertiesMetadata.BUCKET_KEY, "test"); + map.put(PaimonTablePropertiesMetadata.MERGE_ENGINE, "test"); + map.put(PaimonTablePropertiesMetadata.SEQUENCE_FIELD, "test"); + map.put(PaimonTablePropertiesMetadata.ROWKIND_FIELD, "test"); + map.put(PaimonTablePropertiesMetadata.PRIMARY_KEY, "test"); + map.put(PaimonTablePropertiesMetadata.PARTITION, "test"); + + map = Maps.newHashMap(); + map.put("key1", "val1"); + map.put("key2", "val2"); + return map; + } } diff --git a/docs/lakehouse-paimon-catalog.md b/docs/lakehouse-paimon-catalog.md index 03a36408ee3..0822f92b735 100644 --- a/docs/lakehouse-paimon-catalog.md +++ b/docs/lakehouse-paimon-catalog.md @@ -167,6 +167,11 @@ The Gravitino server doesn't allow passing the following reserved fields. |------------------------------------|--------------------------------------------------------------| | `comment` | The table comment. | | `owner` | The table owner. | + +The Gravitino server doesn't allow the following immutable fields to be modified, but allows them to be specified when creating a new table. + +| Configuration item | Description | +|------------------------------------|--------------------------------------------------------------| | `bucket-key` | The table bucket-key. | | `merge-engine` | The table merge-engine. | | `sequence.field` | The table sequence.field. |