From 27005cf927c2b153e3686fe6426be2be2cf0beec Mon Sep 17 00:00:00 2001 From: caican Date: Fri, 11 Oct 2024 20:09:01 +0800 Subject: [PATCH] update --- .../paimon/PaimonTablePropertiesMetadata.java | 9 ++-- .../paimon/TestGravitinoPaimonTable.java | 45 +++++++++---------- 2 files changed, 23 insertions(+), 31 deletions(-) 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 5fb34605554..671dd9d6682 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 @@ -51,18 +51,15 @@ public class PaimonTablePropertiesMetadata extends BasePropertiesMetadata { ImmutableList.of( stringReservedPropertyEntry(COMMENT, "The table comment", true), stringReservedPropertyEntry(OWNER, "The table owner", false), - stringImmutablePropertyEntry( - BUCKET_KEY, "The table bucket key", false, null, false, false), + stringReservedPropertyEntry(BUCKET_KEY, "The table bucket key", 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)); + stringReservedPropertyEntry(PRIMARY_KEY, "The table primary key", false), + stringReservedPropertyEntry(PARTITION, "The table partition", 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 13b0aab6692..466ecb3459d 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,33 +382,41 @@ void testTableProperty() { try (PaimonCatalogOperations ops = new PaimonCatalogOperations()) { ops.initialize( initBackendCatalogProperties(), entity.toCatalogInfo(), PAIMON_PROPERTIES_METADATA); - HashMap properties1 = + HashMap reservedProps = new HashMap() { { put(PaimonTablePropertiesMetadata.COMMENT, "test"); put(PaimonTablePropertiesMetadata.OWNER, "test"); + put(PaimonTablePropertiesMetadata.BUCKET_KEY, "test"); + put(PaimonTablePropertiesMetadata.PRIMARY_KEY, "test"); + put(PaimonTablePropertiesMetadata.PARTITION, "test"); } }; Assertions.assertThrows( IllegalArgumentException.class, () -> PropertiesMetadataHelpers.validatePropertyForCreate( - paimonCatalog.tablePropertiesMetadata(), properties1)); + paimonCatalog.tablePropertiesMetadata(), reservedProps)); Assertions.assertThrows( IllegalArgumentException.class, () -> PropertiesMetadataHelpers.validatePropertyForAlter( - paimonCatalog.tablePropertiesMetadata(), properties1, Collections.emptyMap())); + paimonCatalog.tablePropertiesMetadata(), reservedProps, Collections.emptyMap())); Assertions.assertThrows( IllegalArgumentException.class, () -> PropertiesMetadataHelpers.validatePropertyForAlter( - paimonCatalog.tablePropertiesMetadata(), Collections.emptyMap(), properties1)); + paimonCatalog.tablePropertiesMetadata(), Collections.emptyMap(), reservedProps)); - Map map = Maps.newHashMap(getStringImmutableProperties()); - map.put("key1", "val1"); - map.put("key2", "val2"); - for (Map.Entry entry : map.entrySet()) { + Map immutableProps = + new HashMap() { + { + put(PaimonTablePropertiesMetadata.MERGE_ENGINE, "test"); + put(PaimonTablePropertiesMetadata.SEQUENCE_FIELD, "test"); + put(PaimonTablePropertiesMetadata.ROWKIND_FIELD, "test"); + } + }; + for (Map.Entry entry : immutableProps.entrySet()) { HashMap properties = new HashMap() { { @@ -418,11 +426,13 @@ void testTableProperty() { PropertiesMetadata metadata = paimonCatalog.tablePropertiesMetadata(); Assertions.assertDoesNotThrow( () -> PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties)); - Assertions.assertDoesNotThrow( + Assertions.assertThrows( + IllegalArgumentException.class, () -> PropertiesMetadataHelpers.validatePropertyForAlter( metadata, properties, Collections.emptyMap())); - Assertions.assertDoesNotThrow( + Assertions.assertThrows( + IllegalArgumentException.class, () -> PropertiesMetadataHelpers.validatePropertyForAlter( metadata, Collections.emptyMap(), properties)); @@ -631,19 +641,4 @@ 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; - } }