maropu commented on a change in pull request #24214: [SPARK-27279][SQL] Reuse 
subquery correctly
URL: https://github.com/apache/spark/pull/24214#discussion_r268942226
 
 

 ##########
 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:
   This change fixes the bug you described in the PR description? Sorry, but 
I'm not clearly sure about what's the problem here, so could you show us an 
example query to reproduce the bug? Also, could you make the title more 
precise...?

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