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_r344656433
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/subquery.scala
 ##########
 @@ -194,6 +272,19 @@ 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 expr = if (children.length == 1) {
+          children.head
+        } else {
+          CreateNamedStruct(
+            children.zipWithIndex.flatMap { case (v, index) =>
+              Seq(Literal(s"col_$index"), v)
+            }
+          )
+        }
+        val executedPlan = new QueryExecution(sparkSession, Project(Nil, 
sub)).executedPlan
+        ExistsExec(expr, sub.treeString,
 
 Review comment:
   > Why `ExistsExec` needs a `expr` parameter?
   
   Remove `expr` and `subQuery`

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