Repository navigation
Conversation
update_spec().remove_field(name).add_field(..., name) raised "Cannot add duplicate partition field name" because add_field checked whether the new field's id was being removed instead of the existing field's id. Replacing a partition field while keeping its name, for example to change the number of buckets, works in Java. Check the existing field instead, and on v1 tables rename the removed field, which stays in the spec as a void transform, to name_<field id> as Java does.
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.
Closes #4306
Rationale for this change
update_spec().remove_field(name).add_field(..., name)raisedCannot add duplicate partition field namebecauseadd_fieldchecked whether the new field's id was being removed instead of the existing field's id. Replacing a partition field while keeping its name, for example to change the number of buckets, works in Java (BaseUpdatePartitionSpec.addField).This checks the existing field instead. On v1 tables the removed field stays in the spec as a void transform, so it is renamed to
<name>_<fieldId>, as Java does.Are these changes tested?
Yes:
test_update_spec_remove_and_add_field_with_same_nameintests/table/test_init.pyreplaces a bucket field with a new one of the same name on v1 and v2 tables and checks the resulting spec (on v1 the removed field becomesy_shard_1001with a void transform). It fails onmainand passes with this change.tests/tableandtests/test_schema.py: 889 passed.ruff checkandruff format --check(0.14.3) pass on the changed files.Are there any user-facing changes?
Removing a partition field and adding a new one with the same name in one
update_spec()now works instead of raising.