diff --git a/paimon-core/src/main/java/org/apache/paimon/schema/ColumnDirectiveUtils.java b/paimon-core/src/main/java/org/apache/paimon/schema/ColumnDirectiveUtils.java index ec104bfa3504..34209a8dc34d 100644 --- a/paimon-core/src/main/java/org/apache/paimon/schema/ColumnDirectiveUtils.java +++ b/paimon-core/src/main/java/org/apache/paimon/schema/ColumnDirectiveUtils.java @@ -322,6 +322,25 @@ public static void removeDroppedDirectiveOptions( } } options.remove(String.format("field.%s.vector-dim", fieldName)); + } else if (type.getTypeRoot() == DataTypeRoot.MAP) { + options.remove( + CoreOptions.FIELDS_PREFIX + + "." + + fieldName + + "." + + CoreOptions.MAP_STORAGE_LAYOUT); + options.remove( + CoreOptions.FIELDS_PREFIX + + "." + + fieldName + + "." + + CoreOptions.MAP_SHARED_SHREDDING_MAX_COLUMNS); + options.remove( + CoreOptions.FIELDS_PREFIX + + "." + + fieldName + + "." + + CoreOptions.MAP_SHARED_SHREDDING_COLUMN_PLACEMENT_POLICY); } } diff --git a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java index c9c1a6b5f5a0..4c238781b9b1 100644 --- a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java +++ b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java @@ -94,6 +94,9 @@ import static org.apache.paimon.CoreOptions.IGNORE_RETRACT; import static org.apache.paimon.CoreOptions.IGNORE_UPDATE_BEFORE; import static org.apache.paimon.CoreOptions.LIST_AGG_DELIMITER; +import static org.apache.paimon.CoreOptions.MAP_SHARED_SHREDDING_COLUMN_PLACEMENT_POLICY; +import static org.apache.paimon.CoreOptions.MAP_SHARED_SHREDDING_MAX_COLUMNS; +import static org.apache.paimon.CoreOptions.MAP_STORAGE_LAYOUT; import static org.apache.paimon.CoreOptions.NESTED_KEY; import static org.apache.paimon.CoreOptions.PK_CLUSTERING_OVERRIDE; import static org.apache.paimon.CoreOptions.SEQUENCE_FIELD; @@ -854,7 +857,20 @@ private static Map applyRenameColumnsToOptions( fieldName -> FIELDS_PREFIX + "." + fieldName + "." + AGG_FUNCTION, fieldName -> FIELDS_PREFIX + "." + fieldName + "." + IGNORE_RETRACT, fieldName -> FIELDS_PREFIX + "." + fieldName + "." + DISTINCT, - fieldName -> FIELDS_PREFIX + "." + fieldName + "." + LIST_AGG_DELIMITER); + fieldName -> FIELDS_PREFIX + "." + fieldName + "." + LIST_AGG_DELIMITER, + fieldName -> FIELDS_PREFIX + "." + fieldName + "." + MAP_STORAGE_LAYOUT, + fieldName -> + FIELDS_PREFIX + + "." + + fieldName + + "." + + MAP_SHARED_SHREDDING_MAX_COLUMNS, + fieldName -> + FIELDS_PREFIX + + "." + + fieldName + + "." + + MAP_SHARED_SHREDDING_COLUMN_PLACEMENT_POLICY); for (RenameColumn rename : renameColumns) { String fieldName = rename.fieldNames()[0]; diff --git a/paimon-core/src/test/java/org/apache/paimon/table/MapSharedShreddingTableTest.java b/paimon-core/src/test/java/org/apache/paimon/table/MapSharedShreddingTableTest.java index 35e86d9a1d23..666654231bc3 100644 --- a/paimon-core/src/test/java/org/apache/paimon/table/MapSharedShreddingTableTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/table/MapSharedShreddingTableTest.java @@ -947,6 +947,44 @@ public void testSharedShreddingWithBlobAndVector(String format) throws Exception } } + @ParameterizedTest + @ValueSource(strings = {"orc", "parquet"}) + public void testRenameSharedShreddingMapColumn(String format) throws Exception { + createTable(format, 2, "metrics"); + + catalog.alterTable( + identifier(format), + Collections.singletonList(SchemaChange.renameColumn("metrics", "renamed_metrics")), + false); + + Table table = catalog.getTable(identifier(format)); + assertThat(table.rowType().getFieldNames()).containsExactly("id", "renamed_metrics"); + + Map options = table.options(); + assertThat(options).doesNotContainKey("fields.metrics.map.storage-layout"); + assertThat(options) + .containsEntry("fields.renamed_metrics.map.storage-layout", "shared-shredding") + .containsEntry("fields.renamed_metrics.map.shared-shredding.max-columns", "2"); + } + + @ParameterizedTest + @ValueSource(strings = {"orc", "parquet"}) + public void testDropSharedShreddingMapColumn(String format) throws Exception { + createTable(format, 2, "metrics", "labels"); + + catalog.alterTable( + identifier(format), + Collections.singletonList(SchemaChange.dropColumn("metrics")), + false); + + Table table = catalog.getTable(identifier(format)); + assertThat(table.rowType().getFieldNames()).containsExactly("id", "labels"); + + Map options = table.options(); + assertThat(options).doesNotContainKey("fields.metrics.map.storage-layout"); + assertThat(options).doesNotContainKey("fields.metrics.map.shared-shredding.max-columns"); + } + private Table createTable(String format, String... sharedShreddingFields) throws Exception { return createTable(format, 2, sharedShreddingFields); }