diff --git a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java index f03fa0b1014e..2c8c9aedf791 100644 --- a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java +++ b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java @@ -27,7 +27,9 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.common.StatsSetupConst; import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; @@ -186,7 +188,15 @@ protected void doCommit(TableMetadata base, TableMetadata metadata) { baseMetadataLocation, metadataLocation, database, tableName); } - setHmsTableParameters(newMetadataLocation, tbl, metadata.properties(), hiveEngineEnabled); + // get Iceberg props that have been removed + Set removedProps = Collections.emptySet(); + if (base != null) { + removedProps = base.properties().keySet().stream() + .filter(key -> !metadata.properties().containsKey(key)) + .collect(Collectors.toSet()); + } + + setHmsTableParameters(newMetadataLocation, tbl, metadata.properties(), removedProps, hiveEngineEnabled); persistTable(tbl, updateHiveTable); threw = false; @@ -258,7 +268,7 @@ private Table newHmsTable() { } private void setHmsTableParameters(String newMetadataLocation, Table tbl, Map icebergTableProps, - boolean hiveEngineEnabled) { + Set obsoleteProps, boolean hiveEngineEnabled) { Map parameters = tbl.getParameters(); if (parameters == null) { @@ -268,6 +278,9 @@ private void setHmsTableParameters(String newMetadataLocation, Table tbl, Map !IGNORED_PARAMS.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Assert.assertFalse(hmsParams.containsKey("custom_property")); + Assert.assertFalse(hmsParams.containsKey("new_prop_1")); + Assert.assertTrue(hmsParams.containsKey("new_prop_2")); + } } @Test