Repository navigation
Ignore unset keys when removing table properties - #4522
Conversation
Applying a property removal popped each key, so the commit failed with a KeyError if another writer had already removed the property. Skip keys that aren't set, as the REST catalog does, and treat a removal of only unset keys as a no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fokko
left a comment
There was a problem hiding this comment.
Thanks for fixing this! Tolerating unset keys matches Java's TableMetadata.Builder.removeProperties. One thing to align: the builder still records the RemoveProperties change when none of the keys are set (it only short-circuits on an empty set), so build() produces new metadata and the REST server (CatalogHandlers.commit) writes a new metadata file. _apply_table_update is the equivalent of MetadataUpdate.applyTo(Builder), and the SetPropertiesUpdate handler above already follows the builder this way. Suggestions inline. The Hive integration test still passes with them, since HiveCatalog.commit_table diffs the old and new Iceberg properties to decide what to remove from HMS.
As Java's TableMetadata.Builder.removeProperties does, only an empty removal is skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fokko
left a comment
There was a problem hiding this comment.
LGTM, thanks @smaheshwar-pltr! Nice catch aligning with the Java/Rust/Go behavior, and good test coverage for the concurrent-removal case. 🚀
Fokko
left a comment
There was a problem hiding this comment.
Thanks @smaheshwar-pltr for fixing this, and for checking the Java, Rust, Go and C++ implementations! I've opened #4538 to follow up on a removal that changes nothing still writing a new metadata version.
Rationale for this change
With the SQL, in-memory, Hive and Glue catalogs, PyIceberg applies a commit's changes to the table's latest metadata itself, rather than a REST server doing it. Removing a property deletes each key, so the commit fails if another writer removed the same property first:
The property is gone either way, so this skips keys that aren't set, as REST catalogs and the other implementations do (Java, Rust, Go, C++).
Are these changes tested?
Yes. A catalog test covers the concurrent removal, and a unit test covers unset keys. A Hive integration test expected
KeyErrorwhen removing a Hive Metastore parameter that Iceberg doesn't see; it now checks that the removal leaves the parameter in place.Are there any user-facing changes?
Removing a property that isn't set no longer raises
KeyError, including a key that was never set, as with a REST catalog.AI Disclosure: This PR was authored by Claude Code (Opus 5.5) but directed and overseen by me.