You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/04/18 08:58:34 UTC

[GitHub] [spark] viirya commented on a change in pull request #24344: [SPARK-27440][SQL] Optimize uncorrelated predicate subquery

viirya commented on a change in pull request #24344: [SPARK-27440][SQL] Optimize uncorrelated predicate subquery
URL: https://github.com/apache/spark/pull/24344#discussion_r276573822
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/subquery.scala
 ##########
 @@ -551,3 +552,30 @@ object RewriteCorrelatedScalarSubquery extends Rule[LogicalPlan] {
       }
   }
 }
+
+/**
+ * This rule rewrites uncorrelated PredicateSubquery expressions such as Exists.
+ * The uncorrelated Exists can be evaluated using a subplan instead of a semi-join.
+ * Also, we can use `limit 1` and `select 1` after the subquery to reduce the result set.
+ * Example:
+ * exists(select b from t where t.a = 2) => exists(select 1 from t where t.a = 2 limit 1)
 
 Review comment:
   Can you give a more complete example query for this rewrite? It is beneficial for readers.

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