Repository navigation
Fix append when a data column is named like a partition helper column - #4344
Merged
Fokko merged 2 commits intoNov 11, 2026
Merged
Conversation
_determine_partitions adds the transformed partition values as columns named _partition_<field name>. A data column with the same name made the column lookup ambiguous and the append raised KeyError. Pick helper names that are not already in the table. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
Fokko
approved these changes
Nov 11, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Sounds like an edge case, but reasonable to add. Thanks @rahulsmahadev
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
_determine_partitionsadds the transformed partition values to the Arrow table as temporary columns named_partition_<partition field name>. If the data already has a column with that name, the lookup by name is ambiguous andappend()fails:This change picks helper column names that are not already in the table, by prefixing underscores until the name is free. The helper columns are still dropped before the data files are written.
Are these changes tested?
Yes.
test_determine_partitions_with_column_named_like_partition_helperintests/io/test_pyarrow.pypartitions a table that has a_partition_regiondata column and checks that every row lands in the right partition with that column unchanged. It fails without the fix.Are there any user-facing changes?
Bug fix only: appends to such tables now succeed. No API changes.
This pull request and its description were written by Isaac.