Repository navigation
fix(spec): accept partition specs produced by spec evolution - #3431
Open
dhruvarya-db wants to merge 1 commit into
Open
dhruvarya-db wants to merge 1 commit into
dhruvarya-db wants to merge 1 commit into
Conversation
Partition spec evolution produces specs that the spec builders rejected: - A source column can have more than one partition field. Adding hour(ts) to a spec that has day(ts) is allowed, and format version 1 tables keep each removed field as a `void` placeholder. Binding an unbound spec (`UnboundPartitionSpec::bind`, `PartitionSpecBuilder::new_from_unbound`, and so `TableMetadataBuilder::add_partition_spec`) and loading the legacy v1 `partition-spec` field ran the authoring-time redundancy check and rejected these specs. Both now skip it, as Java does. `PartitionSpecBuilder::add_unbound_field` and `UnboundPartitionSpecBuilder::add_partition_field` still reject redundant fields. - Removing identity(category) from a format version 1 spec leaves a void field named `category`. Both the spec builder and the table metadata builder allowed only identity fields to share the name of their source column. Void fields may now do the same, matching Java's `alwaysNull`. Co-authored-by: Isaac <no-reply@databricks.com>
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.
Which issue does this PR close?
What changes are included in this PR?
Catalogs built on iceberg-rust apply an
AddSpecupdate throughTableMetadataBuilder::add_partition_spec, which binds the spec with the same checks used to author a new one. Those checks reject specs that partition spec evolution legitimately produces, and that Java writes and accepts:updateSpec().addField(hour("ts"))on a table partitioned byday(ts)produces a spec with bothts_dayandts_hour. On a format version 1 table, each removed field stays as avoidplaceholder, so one column can have several void fields. Binding ran the authoring-time redundancy check, soUnboundPartitionSpec::bind,PartitionSpecBuilder::new_from_unboundandTableMetadataBuilder::add_partition_specrejected these specs. Loading v1 metadata that has only the legacypartition-specfield did too. Both now skip the check, as Java'sPartitionSpec.Builder.adddoes.PartitionSpecBuilder::add_unbound_fieldandUnboundPartitionSpecBuilder::add_partition_fieldstill reject redundant fields when authoring a spec.identity(category)from a v1 spec in Java leaves a void field namedcategory. Both the spec builder andTableMetadataBuilder::validate_partition_field_namesallowed only identity fields to share their source column's name. Void fields may now do the same, matching Java'salwaysNull(source, name). Java goes further and allows any transform named after its own source column; this PR doesn't.Metadata with
partition-specsalready loaded, because that field is deserialized without rebinding. Only committing these specs failed.#3413 also edits
validate_partition_field_names, so whichever of the two lands second needs a small rebase.Are these changes tested?
Yes, with unit tests:
TableMetadataBuilder::add_partition_specaccepting the void placeholders of a v1 table;partition-specmetadata with two void fields on one column.Each fails without the fix.
AI Disclosure
This PR was written with Claude Opus 5.5 and reviewed by me.