fix: quote partition field name in sortBy to handle dotted partition fields (#17425) - #17550
Open
waterWang wants to merge 3 commits into
Open
Conversation
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.
Description
When
RewriteManifestsSparkAction.sortBy()is called with a partition field name that contains a dot (e.g., a nested struct field flattened toa.b), the string concatenation insortColumn()producescol("data_file.partition.a.b"). Spark interprets this as a nested field traversal (partition→a→b) rather than a single field nameda.b, causingAnalysisException: [FIELD_NOT_FOUND] No such struct field a in a.b.Root cause
The
sortColumn()method at line 320 builds the Spark column reference by raw string concatenation:When
pcontains a dot (e.g.,a.b), the resulting reference is ambiguous.Fix
Wrap the partition field name in backticks so Spark treats it as a single literal field name:
The sibling class
FixedWriter(which handlesbyte[]) already does it correctly.Affected versions
spark/v3.5spark/v4.0spark/v4.1Testing
The existing tests pass because they use simple partition field names without dots (e.g.,
c1,c2_trunc,c3_bucket). A test case with a dotted partition field name would trigger the bug.Closes #17425