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

    https://github.com/apache/spark/pull/16954#discussion_r103981569
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -1204,64 +1250,36 @@ class Analyzer(
     
             // Category 1:
             // BroadcastHint, Distinct, LeafNode, Repartition, and 
SubqueryAlias
    -        case p: BroadcastHint =>
    -          p
    -        case p: Distinct =>
    -          p
    -        case p: LeafNode =>
    -          p
    -        case p: Repartition =>
    -          p
    -        case p: SubqueryAlias =>
    -          p
    +        case _: BroadcastHint | _: Distinct | _: LeafNode | _: Repartition 
| _: SubqueryAlias =>
     
             // Category 2:
             // These operators can be anywhere in a correlated subquery.
             // so long as they do not host outer references in the operators.
             case p: Sort =>
               failOnOuterReference(p)
    -          p
             case p: RepartitionByExpression =>
               failOnOuterReference(p)
    -          p
     
             // Category 3:
             // Filter is one of the two operators allowed to host correlated 
expressions.
             // The other operator is Join. Filter can be anywhere in a 
correlated subquery.
             case f @ Filter(cond, child) =>
               // Find all predicates with an outer reference.
    -          val (correlated, local) = 
splitConjunctivePredicates(cond).partition(containsOuter)
    +          val (correlated, local) =
    +            splitConjunctivePredicates(cond).partition(containsOuter)
     
               // Find any non-equality correlated predicates
               foundNonEqualCorrelatedPred = foundNonEqualCorrelatedPred || 
correlated.exists {
                 case _: EqualTo | _: EqualNullSafe => false
                 case _ => true
               }
    -
    -          // Rewrite the filter without the correlated predicates if any.
    -          correlated match {
    -            case Nil => f
    -            case xs if local.nonEmpty =>
    -              val newFilter = Filter(local.reduce(And), child)
    -              predicateMap += newFilter -> xs
    -              newFilter
    -            case xs =>
    -              predicateMap += child -> xs
    -              child
    -          }
    +          outerReferences ++= getOuterReferences(correlated)
     
             // Project cannot host any correlated expressions
             // but can be anywhere in a correlated subquery.
             case p @ Project(expressions, child) =>
    --- End diff --
    
    `case p: Project =>`. The same issue in the following `Aggregate`


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