cloud-fan commented on code in PR #41046:
URL: https://github.com/apache/spark/pull/41046#discussion_r1185700324


##########
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`.

Review Comment:
   let's make the comment more explicit
   ```
   // The subquery can be already reused (the same Java object) due to filter 
pushdown
   // of table cache. If it happens, we just need to wrap the current subquery 
with `ReusedSubqueryExec`
   // and no need to update te `reuseMap`.
   ```



-- 
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]

Reply via email to