Skip to content

Commit 3b4a969

Browse files
committed
fix test
1 parent 2bbdfe7 commit 3b4a969

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

tests/integration/test_reads.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def test_hive_critical_properties_always_from_iceberg(catalog: Catalog) -> None:
291291
def test_hive_native_properties_cannot_be_deleted_via_iceberg(catalog: Catalog) -> None:
292292
"""Test that HMS-native properties (set outside Iceberg) cannot be deleted via Iceberg.
293293
294-
HMS-native properties are not visible to Iceberg, so remove_properties has no effect on them.
294+
HMS-native properties are not visible to Iceberg, so remove_properties fails with KeyError.
295295
However, if you first SET an HMS property via Iceberg (making it tracked in Iceberg metadata),
296296
it can then be deleted via Iceberg.
297297
"""
@@ -304,26 +304,33 @@ def test_hive_native_properties_cannot_be_deleted_via_iceberg(catalog: Catalog)
304304
hive_table.parameters["hms_native_prop"] = "native_value"
305305
open_client.alter_table(TABLE_NAME[0], TABLE_NAME[1], hive_table)
306306

307-
# Verify the HMS-native property exists
307+
# Verify the HMS-native property exists in HMS
308308
with hive_client as open_client:
309309
hive_table = open_client.get_table(*TABLE_NAME)
310310
assert hive_table.parameters.get("hms_native_prop") == "native_value"
311311

312-
# Attempt to remove the HMS-native property via Iceberg - should have no effect
313-
# because it's not tracked in Iceberg metadata (not visible to Iceberg)
314-
table.transaction().remove_properties("hms_native_prop").commit_transaction()
312+
# Refresh the Iceberg table to get the latest state
313+
table.refresh()
314+
315+
# Verify the HMS-native property is NOT visible in Iceberg
316+
assert "hms_native_prop" not in table.properties
317+
318+
# Attempt to remove the HMS-native property via Iceberg - this should fail
319+
# because the property is not tracked in Iceberg metadata (not visible to Iceberg)
320+
with pytest.raises(KeyError):
321+
table.transaction().remove_properties("hms_native_prop").commit_transaction()
315322

316323
# HMS-native property should still exist (cannot be deleted via Iceberg)
317324
with hive_client as open_client:
318325
hive_table = open_client.get_table(*TABLE_NAME)
319326
assert hive_table.parameters.get("hms_native_prop") == "native_value", (
320-
"HMS-native property should NOT be deletable via Iceberg since it's not visible to Iceberg!"
327+
"HMS-native property should still exist since Iceberg removal failed!"
321328
)
322329

323330
# Now SET the same property via Iceberg (this makes it tracked in Iceberg metadata)
324331
table.transaction().set_properties({"hms_native_prop": "iceberg_value"}).commit_transaction()
325332

326-
# Verify it's updated
333+
# Verify it's updated in both places
327334
with hive_client as open_client:
328335
hive_table = open_client.get_table(*TABLE_NAME)
329336
assert hive_table.parameters.get("hms_native_prop") == "iceberg_value"

0 commit comments

Comments
 (0)