-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-43376][SQL][FOLLOWUP] lazy construct subquery to improve reuse subquery #41454
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
Conversation
| val subquery = SubqueryExec.createForScalarSubquery( | ||
| s"subquery#${exprId.id}", executedPlan) | ||
| subqueryMap.put(exprId.id, subquery) | ||
| subqueryMap.put(exprId.id, executedPlan) |
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.
seems now all subqueries have the same handling code, can we just match the logical subqueries here and build the map?
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.
yeas, cleaned up these code
| name, broadcastKeyIndex, onlyInBroadcast, | ||
| buildPlan, buildKeys, executedPlan) | ||
| subqueryMap.put(exprId.id, subquery) | ||
| case subquery: SubqueryExpression if !subqueryMap.contains(subquery.exprId.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.
to be conservative, how about case subquery @ (_: ScalarSubquery | _: InSubquery | _: DynamicPruningSubquery) => ...
|
@cloud-fan the failed test seems irrelevant |
|
thanks, merging to master! |
… subquery ### What changes were proposed in this pull request? apache#41046 make `ReuseAdaptiveSubquery` become not idempotent. This pr reverts the change in `ReuseAdaptiveSubquery`. To solve the same instance issue when planning and reusing subquery in AQE, this pr makes `subqueryMap` hold the executed plan in subquery. Then in `PlanAdaptiveSubqueries`, each logical subquery plan can build their own instance of physical subquery. ### Why are the changes needed? To improve reuse subquery in AQE. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Pass CI Closes apache#41454 from ulysses-you/SPARK-43376-2. Authored-by: ulysses-you <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
#41046 make
ReuseAdaptiveSubquerybecome not idempotent. This pr reverts the change inReuseAdaptiveSubquery.To solve the same instance issue when planning and reusing subquery in AQE, this pr makes
subqueryMaphold the executed plan in subquery. Then inPlanAdaptiveSubqueries, each logical subquery plan can build their own instance of physical subquery.Why are the changes needed?
To improve reuse subquery in AQE.
Does this PR introduce any user-facing change?
no
How was this patch tested?
Pass CI