adrian-wang commented on a change in pull request #24214: [SPARK-27279][SQL]
Reuse subquery correctly
URL: https://github.com/apache/spark/pull/24214#discussion_r268957962
##########
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:
Thanks for the review, you can see the example in the added test.
----------------------------------------------------------------
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]