mgaido91 commented on a change in pull request #24214: [SPARK-27279][SQL] Reuse 
subquery should compare child plan of `SubqueryExec`
URL: https://github.com/apache/spark/pull/24214#discussion_r269133230
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/subquery.scala
 ##########
 @@ -125,15 +125,15 @@ case class PlanSubqueries(sparkSession: SparkSession) 
extends Rule[SparkPlan] {
 case class ReuseSubquery(conf: SQLConf) extends Rule[SparkPlan] {
 
   def apply(plan: SparkPlan): SparkPlan = {
-    if (!conf.exchangeReuseEnabled) {
+    if (!conf.subqueryReuseEnabled) {
       return plan
     }
     // Build a hash map using schema of subqueries to avoid O(N*N) sameResult 
calls.
     val subqueries = mutable.HashMap[StructType, ArrayBuffer[SubqueryExec]]()
     plan transformAllExpressions {
       case sub: ExecSubqueryExpression =>
         val sameSchema = subqueries.getOrElseUpdate(sub.plan.schema, 
ArrayBuffer[SubqueryExec]())
-        val sameResult = sameSchema.find(_.sameResult(sub.plan))
+        val sameResult = sameSchema.find(_.child.sameResult(sub.plan.child))
 
 Review comment:
   I am not sure either about this fix. I remember this problem which I tried 
to fix in 
https://github.com/apache/spark/pull/22518/commits/36fa664c6d251901270984115ff2ebfd1b665fca.
 As you can see, the PR didn't actually do this fix as per @cloud-fan 's 
comment. So I am pinging him here for reviewing this too. Anyway, when I 
debugged it, the problem was that being the same object according to equals, 
the tree was not updated, so I see no reason for the current fix.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to