[SPARK-55819][SQL] Refactor ExpandExec to be more succinct#54601
Open
eason-yuchen-liu wants to merge 4 commits intoapache:masterfrom
Open
[SPARK-55819][SQL] Refactor ExpandExec to be more succinct#54601eason-yuchen-liu wants to merge 4 commits intoapache:masterfrom
eason-yuchen-liu wants to merge 4 commits intoapache:masterfrom
Conversation
HeartSaVioR
reviewed
Mar 4, 2026
|
|
||
| val groupIterator = groups.iterator | ||
| iter.flatMap { input => | ||
| groupIterator.map { group => |
Contributor
There was a problem hiding this comment.
Don't we need to create an iterator per input? You only traverse groups once among all inputs.
Contributor
There was a problem hiding this comment.
The first commit seems to be the right one for me.
Contributor
Author
There was a problem hiding this comment.
Right was think of object reuse but it will not work. Reverting the change.
Contributor
|
cc. @cloud-fan |
cloud-fan
reviewed
Mar 4, 2026
| @@ -57,31 +57,11 @@ case class ExpandExec( | |||
| val numOutputRows = longMetric("numOutputRows") | |||
|
|
|||
| child.execute().mapPartitionsWithIndexInternal { (index, iter) => | |||
| val groups = projections.map(projection).toArray | |||
Contributor
Author
There was a problem hiding this comment.
Oops, my bad. Missing to revert this.
cloud-fan
approved these changes
Mar 4, 2026
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?
The implementation of
ExpandExecis unnecessarily convoluted. It makes it hard to understand for such a simple logic. This PR tries to simplify it by using all native Iterator transformations.Why are the changes needed?
Makes the code better, and easier to understand.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing UT. (Also manually verified, and asked Claude to verify.)
Was this patch authored or co-authored using generative AI tooling?
No.