@@ -175,8 +175,48 @@ def test_hive_preserves_hms_specific_properties(catalog: Catalog) -> None:
175175
176176@pytest .mark .integration
177177@pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" )])
178- def test_hive_iceberg_property_takes_precedence (catalog : Catalog ) -> None :
179- """Test that Iceberg properties take precedence over conflicting HMS properties.
178+ def test_iceberg_property_deletion_not_restored_from_old_hms_state (catalog : Catalog ) -> None :
179+ """Test that deleted Iceberg properties are truly removed and not restored from old HMS state.
180+
181+ When a property is removed through Iceberg, it should be deleted from HMS and not
182+ come back from the old HMS state during merge operations.
183+ """
184+ table = create_table (catalog )
185+ hive_client : _HiveClient = _HiveClient (catalog .properties ["uri" ])
186+
187+ # Set multiple Iceberg properties
188+ table .transaction ().set_properties ({"prop_to_keep" : "keep_value" , "prop_to_delete" : "delete_me" }).commit_transaction ()
189+
190+ # Verify both properties exist
191+ with hive_client as open_client :
192+ hive_table = open_client .get_table (* TABLE_NAME )
193+ assert hive_table .parameters .get ("prop_to_keep" ) == "keep_value"
194+ assert hive_table .parameters .get ("prop_to_delete" ) == "delete_me"
195+
196+ # Delete one property through Iceberg
197+ table .transaction ().remove_properties ("prop_to_delete" ).commit_transaction ()
198+
199+ # Verify property is deleted from HMS
200+ with hive_client as open_client :
201+ hive_table = open_client .get_table (* TABLE_NAME )
202+ assert hive_table .parameters .get ("prop_to_keep" ) == "keep_value"
203+ assert hive_table .parameters .get ("prop_to_delete" ) is None , "Deleted property should not exist in HMS!"
204+
205+ # Perform another Iceberg commit
206+ table .transaction ().set_properties ({"new_prop" : "new_value" }).commit_transaction ()
207+
208+ # Ensure deleted property doesn't come back from old state
209+ with hive_client as open_client :
210+ hive_table = open_client .get_table (* TABLE_NAME )
211+ assert hive_table .parameters .get ("prop_to_keep" ) == "keep_value"
212+ assert hive_table .parameters .get ("new_prop" ) == "new_value"
213+ assert hive_table .parameters .get ("prop_to_delete" ) is None , "Deleted property should NOT be restored from old HMS state!"
214+
215+
216+ @pytest .mark .integration
217+ @pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" )])
218+ def test_iceberg_metadata_is_source_of_truth (catalog : Catalog ) -> None :
219+ """Test that Iceberg metadata is the source of truth for all Iceberg-managed properties.
180220
181221 If an external tool sets an HMS property with the same name as an Iceberg-managed
182222 property, Iceberg's value should win during commits.
0 commit comments