Resolve staged renames when moving columns in UpdateSchema#3687
Open
Sanjays2402 wants to merge 1 commit into
Open
Resolve staged renames when moving columns in UpdateSchema#3687Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
Fixes apache#2599. rename_column stages the new name in self._updates, but move_first/move_before/move_after resolved the target via the original schema, so moving a column by its new name in the same update context raised 'Cannot move missing column'. _find_for_move now checks staged renames first, matching the Java implementation.
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 #2599
Rationale for this change
rename_columnstages the new column name inself._updates, butmove_first/move_before/move_afterresolved the target column viaself._schema.find_field(...)against the original schema. Moving a column by its new name within the same update context therefore raisedValueError: Cannot move missing column.Reproduction (reported via AWS Glue, but reproduces fully in-memory with
InMemoryCatalog— it is not Glue-specific):_find_for_movenow checks staged renames inself._updatesfirst (respecting_case_sensitive) before falling back to the original schema, matching the Java implementation which resolves staged renames.Are these changes tested?
Yes. Added
tests/table/test_update_schema.pycovering rename-then-move by new name formove_first,move_before, andmove_afterusingInMemoryCatalog.ValueError: Cannot move missing column.ruff checkandruff format --checkare clean on both changed files.Are there any user-facing changes?
No API changes. This fixes incorrect behavior: renaming a column and then moving it by its new name within the same
update_schema()context now works instead of raisingValueError.