[SPARK-58324][SQL] Drop unused sameOrderExpressions from GroupPartitionsExec k-way merge ordering#57503
Closed
peter-toth wants to merge 1 commit into
Closed
Conversation
…onsExec k-way merge ordering ### What changes were proposed in this pull request? `GroupPartitionsExec` builds a `SortedMergeCoalescedRDD` for the k-way merge and hands it a `LazyCodeGenOrdering` built from `child.outputOrdering`. The generated comparator (`GenerateOrdering`) only needs each `SortOrder`'s sort key (child, direction, null ordering), so this drops `sameOrderExpressions` -- planner-only metadata -- via a small `kWayMergeOrdering` helper before constructing the ordering, so it is not serialized with the RDD in every task. ### Why are the changes needed? `sameOrderExpressions` is unused by the comparator and is unnecessary payload serialized with every task. It was also the vector for the StackOverflowError fixed in SPARK-58323 (an unforced, deeply-nested `LazyList`); not carrying it here removes this operator's exposure to any such ordering entirely (defense-in-depth), independent of that fix. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? New unit test in `GroupPartitionsExecSuite` asserting `kWayMergeOrdering` keeps the sort key but drops `sameOrderExpressions`. Existing SPARK-55715 sorted-merge tests cover comparator correctness. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8
anuragmantri
approved these changes
Jul 24, 2026
anuragmantri
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks @peter-toth
uros-b
approved these changes
Jul 24, 2026
peter-toth
added a commit
that referenced
this pull request
Jul 25, 2026
…onsExec k-way merge ordering ### What changes were proposed in this pull request? `GroupPartitionsExec` builds a `SortedMergeCoalescedRDD` for the k-way merge and hands it a `LazyCodeGenOrdering` built from `child.outputOrdering`. The generated comparator (`GenerateOrdering`) only needs each `SortOrder`'s sort key (child, direction, null ordering), so this drops `sameOrderExpressions` -- planner-only metadata -- via a small `kWayMergeOrdering` helper before constructing the ordering, so it is not serialized with the RDD in every task. ### Why are the changes needed? `sameOrderExpressions` is unused by the merge comparator and is unnecessary payload serialized with every task. It was also the vector for the `StackOverflowError` fixed in SPARK-58323 (an unforced, deeply-nested `LazyList`); not carrying it here removes this operator's exposure to any such ordering entirely (defense-in-depth), independent of that fix. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New unit test in `GroupPartitionsExecSuite` asserting `kWayMergeOrdering` keeps the sort key but drops `sameOrderExpressions`. Existing SPARK-55715 sorted-merge tests cover comparator correctness. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Closes #57503 from peter-toth/SPARK-58324-drop-sameorderexpressions-kway-merge. Authored-by: Peter Toth <peter.toth@gmail.com> Signed-off-by: Peter Toth <peter.toth@gmail.com> (cherry picked from commit cce4355) Signed-off-by: Peter Toth <peter.toth@gmail.com>
peter-toth
added a commit
that referenced
this pull request
Jul 25, 2026
…onsExec k-way merge ordering ### What changes were proposed in this pull request? `GroupPartitionsExec` builds a `SortedMergeCoalescedRDD` for the k-way merge and hands it a `LazyCodeGenOrdering` built from `child.outputOrdering`. The generated comparator (`GenerateOrdering`) only needs each `SortOrder`'s sort key (child, direction, null ordering), so this drops `sameOrderExpressions` -- planner-only metadata -- via a small `kWayMergeOrdering` helper before constructing the ordering, so it is not serialized with the RDD in every task. ### Why are the changes needed? `sameOrderExpressions` is unused by the merge comparator and is unnecessary payload serialized with every task. It was also the vector for the `StackOverflowError` fixed in SPARK-58323 (an unforced, deeply-nested `LazyList`); not carrying it here removes this operator's exposure to any such ordering entirely (defense-in-depth), independent of that fix. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New unit test in `GroupPartitionsExecSuite` asserting `kWayMergeOrdering` keeps the sort key but drops `sameOrderExpressions`. Existing SPARK-55715 sorted-merge tests cover comparator correctness. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Closes #57503 from peter-toth/SPARK-58324-drop-sameorderexpressions-kway-merge. Authored-by: Peter Toth <peter.toth@gmail.com> Signed-off-by: Peter Toth <peter.toth@gmail.com> (cherry picked from commit cce4355) Signed-off-by: Peter Toth <peter.toth@gmail.com>
Contributor
Author
Contributor
Author
|
Thank you everyone for the review! |
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?
GroupPartitionsExecbuilds aSortedMergeCoalescedRDDfor the k-way merge and hands it aLazyCodeGenOrderingbuilt fromchild.outputOrdering. The generated comparator (GenerateOrdering) only needs eachSortOrder's sort key (child, direction, null ordering), so this dropssameOrderExpressions-- planner-only metadata -- via a smallkWayMergeOrderinghelper before constructing the ordering, so it is not serialized with the RDD in every task.Why are the changes needed?
sameOrderExpressionsis unused by the merge comparator and is unnecessary payload serialized with every task. It was also the vector for theStackOverflowErrorfixed in SPARK-58323 (an unforced, deeply-nestedLazyList); not carrying it here removes this operator's exposure to any such ordering entirely (defense-in-depth), independent of that fix.Does this PR introduce any user-facing change?
No.
How was this patch tested?
New unit test in
GroupPartitionsExecSuiteassertingkWayMergeOrderingkeeps the sort key but dropssameOrderExpressions. Existing SPARK-55715 sorted-merge tests cover comparator correctness.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8