peter-toth commented on code in PR #41046:
URL: https://github.com/apache/spark/pull/41046#discussion_r1185758279
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/ReuseAdaptiveSubquery.scala:
##########
@@ -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 =>
+ sub.withNewPlan(ReusedSubqueryExec(subquery))
+ }.getOrElse {
+ reuseMap.put(sub.plan.canonicalized, sub.plan)
Review Comment:
Is this correct? 2 concurent `.get()`s for 2 semantic equal plans can return
`None`s and none of the plans will be wrapped into `ReusedSubqueryExec`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]