Repository navigation
Keep per-column properties in sync when renaming or dropping columns - #4616
Open
rahulsmahadev wants to merge 4 commits into
Open
rahulsmahadev wants to merge 4 commits into
rahulsmahadev wants to merge 4 commits into
Conversation
update_schema() left properties keyed by column name, such as write.metadata.metrics.column.<name>, under the old name: a renamed column lost its metrics mode, and a column added under a dropped column's name inherited it. UpdateSchema now moves them to the column's new full name, or removes them when the column is gone, as Java's SchemaUpdate does (apache/iceberg#18885). Co-authored-by: Isaac <no-reply@databricks.com>
A field in a list or map can have a full-name key (points.element.lat) and a short-name key (points.lat). A rename moved both to the same new key and the one read last won, which could change the mode the writer applies. Use the full-name key's value, and pin the case-sensitive key lookup and a rename onto an unresolved key in the tests. Co-authored-by: Isaac <no-reply@databricks.com>
A short-name key such as points.lat with no full-name key next to it moves to the full name on rename, as Java's helper does. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Fokko
approved these changes
Dec 4, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Nice find, and solid port of Java's PropertyUtil.applySchemaChanges @rahulsmahadev! Verified that the 8 prefixes in COLUMN_PROPERTY_PREFIXES match Java main exactly, and that the added tests fail on main. The full-name key taking precedence over a short-name key is a sane difference too. 🚀
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Bug: per-column table properties like
write.metadata.metrics.column.<name>are keyed by column name, andupdate_schema()leaves them under the old name. A renamed column loses its metrics mode, and a column added later under a dropped column's name gets the dropped column's mode:This affects tables with a metrics mode or bloom filter set on a column that PyIceberg renames or drops. A stale metrics key also makes later Java property updates on the table, such as Spark's
ALTER TABLE ... SET TBLPROPERTIES, fail withInvalid metrics config, could not find column email ....Fix: when
UpdateSchemacommits, move each per-column property to its column's new full name, or remove it when the column is gone, nested fields of a renamed or dropped struct included. This portsPropertyUtil.applySchemaChanges, which Java'sSchemaUpdateruns on commit (the step Spark'sALTER TABLE ... RENAME COLUMNandDROP COLUMNgo through), with the same 8 prefixes (TableProperties.COLUMN_PROPERTY_PREFIXES). This is Java main since apache/iceberg#18885 and not released yet; 1.12.0 syncs 3 of the prefixes, for the renamed or dropped column only. PyIceberg's writer only applieswrite.metadata.metrics.column.; the others are kept in sync for engines that read them from the same table.Difference from Java main:
points.latforpoints.element.lat), the full-name key, which the writers apply, wins on rename; Java's helper keeps whichever it reads last. A short-name key alone moves to the full name, as in Java, so writers start to apply it.Are these changes tested?
Yes, added
test_update_schema_moves_column_properties,test_update_schema_column_properties_in_transaction(all 8 prefixes, renames into a dropped column's name and onto a key that matches no column, a key that differs from a column only by case, properties set earlier in the same transaction) andtest_update_schema_prefers_full_name_column_property(both key orders, checked through the written metrics, and a short-name key alone) totests/table/test_init.py, for each catalog of thecatalogfixture. All three fail on main, where the properties keep their old names, and pass with this change.Are there any user-facing changes?
Yes, renaming or dropping a column now renames or removes its per-column table properties, and
TablePropertiesgetsCOLUMN_PROPERTY_PREFIXESplus constants for the six Java per-column Parquet prefixes it was missing.Please add the
changeloglabel.This pull request and its description were written by Isaac.