-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-50683][SQL] Inline the common expression in With if used once #49310
Conversation
cc @cloud-fan Thank you. |
CI failure is not relevant. |
@@ -68,9 +68,15 @@ object RewriteWithExpression extends Rule[LogicalPlan] { | |||
|
|||
private def applyInternal(p: LogicalPlan): LogicalPlan = { | |||
val inputPlans = p.children | |||
val commonExprIdSet = p.expressions | |||
.flatMap(_.collect { case r: CommonExpressionRef => r.id }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid collecting references from nested With, as this rule skips nested With and leaves it to the next iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think collecting references from nested With is necessary, e.g. With(ref0 + With(ref1 + ref1, Seq(def(ref0+b,1))), Seq(def(a+a,0)))
, first iteration will replace all ref0.
This will collect additional ref1, but it will not affect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping gently @cloud-fan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, makes sense
The Spark Connect test failure is unrelated, thanks, merging to master! |
What changes were proposed in this pull request?
As title.
Why are the changes needed?
Simplify plan and reduce unnecessary project.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
UT.
Was this patch authored or co-authored using generative AI tooling?
No.