AngersZhuuuu commented on a change in pull request #26437: [SPARK-29800][SQL]
Plan non-correlated Exists 's subquery in PlanSubqueries
URL: https://github.com/apache/spark/pull/26437#discussion_r345635193
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/subquery.scala
##########
@@ -194,6 +258,9 @@ case class PlanSubqueries(sparkSession: SparkSession)
extends Rule[SparkPlan] {
}
val executedPlan = new QueryExecution(sparkSession, query).executedPlan
InSubqueryExec(expr, SubqueryExec(s"subquery#${exprId.id}",
executedPlan), exprId)
+ case expressions.Exists(sub, children, exprId) =>
+ val executedPlan = new QueryExecution(sparkSession, Project(Nil,
sub)).executedPlan
Review comment:
Lose reference `id#256`
```
== Parsed Logical Plan ==
'Project ['s1.id]
+- 'Filter exists#258 []
: +- 'Project [*]
: +- 'Filter ('s3.id = 's1.id)
: +- 'UnresolvedRelation [s3]
+- 'Join Inner, ('s1.id = 's2.id)
:- 'UnresolvedRelation [s1]
+- 'UnresolvedRelation [s2]
== Analyzed Logical Plan ==
id: int
Project [id#244]
+- Filter exists#258 [id#244]
: +- Project [id#256]
: +- Filter (id#256 = outer(id#244))
: +- SubqueryAlias `s3`
: +- Project [value#253 AS id#256]
: +- LocalRelation [value#253]
+- Join Inner, (id#244 = id#250)
:- SubqueryAlias `s1`
: +- Project [value#241 AS id#244]
: +- LocalRelation [value#241]
+- SubqueryAlias `s2`
+- Project [value#247 AS id#250]
+- LocalRelation [value#247]
== Optimized Logical Plan ==
!Join LeftSemi, (id#256 = id#244)
:- Project [id#244]
: +- Join Inner, (id#244 = id#250)
: :- Project [value#241 AS id#244]
: : +- LocalRelation [value#241]
: +- Project [value#247 AS id#250]
: +- LocalRelation [value#247]
+- Project
+- LocalRelation [value#253]
== Physical Plan ==
!BroadcastNestedLoopJoin BuildRight, LeftSemi, (id#256 = id#244)
:- *(2) Project [id#244]
: +- *(2) BroadcastHashJoin [id#244], [id#250], Inner, BuildRight
: :- *(2) Project [value#241 AS id#244]
: : +- *(2) LocalTableScan [value#241]
: +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[0,
int, false] as bigint))), [id=#129]
: +- *(1) Project [value#247 AS id#250]
: +- *(1) LocalTableScan [value#247]
+- BroadcastExchange IdentityBroadcastMode, [id=#135]
+- *(3) Project
+- *(3) LocalTableScan [value#253]
```
----------------------------------------------------------------
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]