[SPARK-56164][SQL] Fix SPJ merged key ordering#54961
Open
peter-toth wants to merge 5 commits intoapache:masterfrom
Open
[SPARK-56164][SQL] Fix SPJ merged key ordering#54961peter-toth wants to merge 5 commits intoapache:masterfrom
peter-toth wants to merge 5 commits intoapache:masterfrom
Conversation
Contributor
Author
|
cc @szehon-ho , @dongjoon-hyun |
Member
There was a problem hiding this comment.
Thank you, @peter-toth . This is only for 4.2.0, right?
This PR fixes a theoretical bug, a real world example is unlikely to exist.
Contributor
Author
Yes, I intend to fix in 4.2 only. I'm working on a new feature that can make this bug appear in real world scenarios. |
| fn | ||
| } | ||
| catalog.createFunction(id, fn) | ||
| def withFunctions[T](fns: UnboundFunction*)(f: => T): T = { |
Member
There was a problem hiding this comment.
We don't use plural form for the helper functions, do we? The previous name withFunction looks better to me.
dongjoon-hyun
approved these changes
Mar 23, 2026
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM (with only one nit naming comment).
szehon-ho
reviewed
Mar 23, 2026
...ore/src/test/scala/org/apache/spark/sql/connector/catalog/functions/transformFunctions.scala
Outdated
Show resolved
Hide resolved
szehon-ho
approved these changes
Mar 23, 2026
sql/core/src/test/scala/org/apache/spark/sql/connector/KeyGroupedPartitioningSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
Outdated
Show resolved
Hide resolved
3eb6436 to
5daa4a7
Compare
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.
What changes were proposed in this pull request?
Fix a bug in
EnsureRequirementswhere the ordering used to merge and dedup partition keys after reduction was based on the original partition key types rather than the reduced types.When compatible partition transform reducers are applied (e.g. reducing days keys to years keys), the resulting partition key values may have a different
DataTypethan the originals.Please note that #54884 fixed the issue when left and right side reduced key types are not equal, but this PR fixes the issue when the common reduced types differ to the left side original types.
Why are the changes needed?
Without this fix, when reducers change the data type of partition keys (e.g.
DateType→LongType), the ordering used to merge partition values is built for the wrong type, which can produce incorrect merge results or runtime failures during storage-partitioned joins with compatible transform reducers.Does this PR introduce any user-facing change?
This PR fixes a theoretical bug, a real world example is unlikely to exist.
How was this patch tested?
Added a new test case.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Sonnet 4.6