spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] AngersZhuuuu commented on a change in pull request #26437: [SPARK-29800][SQL] Plan Exists 's subquery in PlanSubqueries
Date Sat, 09 Nov 2019 03:01:07 GMT
AngersZhuuuu commented on a change in pull request #26437: [SPARK-29800][SQL] Plan Exists 's
subquery in PlanSubqueries
URL: https://github.com/apache/spark/pull/26437#discussion_r344426021
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/subquery.scala
 ##########
 @@ -171,6 +171,63 @@ case class InSubqueryExec(
   }
 }
 
+/**
+ * The physical node of exists-subquery. This is for support use exists in join's on condition,
+ * since some join type we can't pushdown exists condition, we plan it here
+ */
+case class ExistsExec(child: Expression,
+                      subQuery: String,
+                      plan: BaseSubqueryExec,
+                      exprId: ExprId,
+                      private var resultBroadcast: Broadcast[Boolean] = null)
+  extends ExecSubqueryExpression {
+
+  @transient private var result: Boolean = _
+
+  override def dataType: DataType = BooleanType
+  override def children: Seq[Expression] = child :: Nil
+  override def nullable: Boolean = child.nullable
+  override def toString: String = s"EXISTS ${plan.name}"
+  override def withNewPlan(plan: BaseSubqueryExec): ExistsExec = copy(plan = plan)
+
+  override def semanticEquals(other: Expression): Boolean = other match {
+    case in: ExistsExec => child.semanticEquals(in.child) && plan.sameResult(in.plan)
+    case _ => false
+  }
+
+
+  def updateResult(): Unit = {
+    result = !plan.execute().isEmpty()
 
 Review comment:
   @dilipbiswal 
   ```
   SELECT * FROM T1 JOIN T2 ON T1.C1 = T2.C1 AND T1.C1 EXISTS (SELECT 1 FROM T3 WHERE T1.C1
= T3.C1)
   ```
    Is not correct .
   
   You mean  below ?
   ```
   SELECT * FROM T1 JOIN T2 ON T1.C1 = T2.C1 AND EXISTS (SELECT 1 FROM T3 WHERE T1.C1 = T3.C1)
   ```
   
   For this type sql we need to change `RewritePredicateSubquery` as cloud-fan said.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message