-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-43376][SQL] Improve reuse subquery with table cache #41046
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,10 +33,13 @@ case class ReuseAdaptiveSubquery( | |
|
|
||
| plan.transformAllExpressionsWithPruning(_.containsPattern(PLAN_EXPRESSION)) { | ||
| case sub: ExecSubqueryExpression => | ||
| val newPlan = reuseMap.getOrElseUpdate(sub.plan.canonicalized, sub.plan) | ||
| if (newPlan.ne(sub.plan)) { | ||
| sub.withNewPlan(ReusedSubqueryExec(newPlan)) | ||
| } else { | ||
| // `InsertAdaptiveSparkPlan` compiles subquery for each exprId, then the java object | ||
| // is always `eq` if two subqueries have same exprId. | ||
| // Check if the subquery can be reused manually instead of call `getOrElseUpdate`. | ||
| reuseMap.get(sub.plan.canonicalized).map { subquery => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed that this rule is not idempotent now. If we run it twice, then all subqueries will become |
||
| sub.withNewPlan(ReusedSubqueryExec(subquery)) | ||
| }.getOrElse { | ||
| reuseMap.put(sub.plan.canonicalized, sub.plan) | ||
|
||
| sub | ||
| } | ||
| } | ||
|
|
||
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.
let's make the comment more explicit
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.
addressed