Repository navigation
Conversation
PartitionKey.partition looked up each partition field by its source column and raised "Cannot have redundant partitions" when the spec had more than one field on that column. Specs like bucket(id) plus truncate(id) are valid, and a format v1 table gets one whenever a partition field on a column is replaced, because the removed field stays as a void transform. Appends, overwrites and deletes to such tables failed. Each PartitionFieldValue already carries its partition field, so use it directly.
Contributor
Author
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.
Closes #4536
Rationale for this change
PartitionKey.partitionlooked up each partition field by its source column and raisedCannot have redundant partitionswhen the spec had more than one field on that column. Specs likebucket(id)plustruncate(id)are valid, and Java and Spark write them. A format v1 table also ends up with one whenever a partition field on a column is replaced, for example to change the bucket count, because the removed field stays in the spec as avoidtransform of the same column. Appends, overwrites and deletes that rewrite part of a data file all failed on these tables.Each
PartitionFieldValuealready carries the partition field it was computed for, soPartitionKey.partitionnow uses that field instead of looking it up by source column. Specs with one field per source column produce the same partition records as before.An earlier attempt at this, #4092, was closed by the stale bot without review.
Are these changes tested?
Yes.
test_append_to_table_with_multiple_partition_fields_on_one_columnintests/catalog/test_catalog_behaviors.pyruns against the memory and SQL catalogs. It appends to a table partitioned bybucket(4, id)andtruncate(10, id)and checks the partition values and a filtered scan. It then changes the bucket count of a format v1 table, appends again, and checks the new partition values (nullfor the void field) and the rows. The test fails on main with theValueErrorand passes with this change.make lintpasses, andmake testgives 4965 passed, 6 skipped, 129 deselected.Are there any user-facing changes?
Yes. Writes to tables with more than one partition field on the same column now succeed instead of raising
ValueError.