Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3249#discussion_r22004038
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -314,6 +318,113 @@ class Analyzer(catalog: Catalog, registry: 
FunctionRegistry, caseSensitive: Bool
         protected def containsStar(exprs: Seq[Expression]): Boolean =
           exprs.collect { case _: Star => true }.nonEmpty
       }
    +
    +  /**
    +   * Transforms the query which has subquery expressions in where clause 
to join queries.
    +   * Case 1 Uncorelated queries
    +   * -- original query
    +   * select C from R1 where R1.A in (Select B from R2)
    +   * -- rewritten query
    +   * Select C from R1 left semi join (select B as sqc0 from R2) subquery 
on R1.A = subquery.sqc0
    +   *
    +   * Case 2 Corelated queries
    +   * -- original query
    +   * select C from R1 where R1.A in (Select B from R2 where R1.X = R2.Y)
    +   * -- rewritten query
    +   * select C from R1 left semi join (select B as sqc0, R2.Y as sqc1 from 
R2) subquery
    +   *   on R1.X = subquery.sqc1 and R1.A = subquery.sqc0
    +   * 
    +   * Refer: 
https://issues.apache.org/jira/secure/attachment/12614003/SubQuerySpec.pdf
    +   */
    +  object SubQueryExpressions extends Rule[LogicalPlan] {
    +
    +    def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +      case filter @ Filter(conditions, child) =>
    +        val subqueryExprs = new 
scala.collection.mutable.ArrayBuffer[SubqueryExpression]()
    +        val nonSubQueryConds = new 
scala.collection.mutable.ArrayBuffer[Expression]()
    +        val transformedConds = conditions.transform{
    --- End diff --
    
    Space before `{`.
    
    Also I would consider doing this in two steps to avoid depending on 
transform for side effects: a collect to get the list and then a transform to 
replace with `true`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to