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

    https://github.com/apache/spark/pull/12539#discussion_r60698757
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -862,28 +862,68 @@ class Analyzer(
       object ResolveSubquery extends Rule[LogicalPlan] with PredicateHelper {
     
         /**
    -     * Resolve the correlated predicates in the [[Filter]] clauses (e.g. 
WHERE or HAVING) of a
    +     * Resolve the correlated predicates in the clauses (e.g. WHERE or 
HAVING) of a
          * sub-query by using the plan the predicates should be correlated to.
          */
    -    private def resolveCorrelatedPredicates(q: LogicalPlan, p: 
LogicalPlan): LogicalPlan = {
    -      q transformUp {
    -        case f @ Filter(cond, child) if child.resolved && !f.resolved =>
    -          val newCond = resolveExpression(cond, p, throws = false)
    -          if (!cond.fastEquals(newCond)) {
    -            Filter(newCond, child)
    -          } else {
    -            f
    -          }
    +    private def resolveCorrelatedSubquery(
    +        sub: LogicalPlan, outer: LogicalPlan,
    +        aliases: scala.collection.mutable.Map[Attribute, Alias]): 
LogicalPlan = {
    +      // First resolve as much of the sub-query as possible
    +      val analyzed = execute(sub)
    +      if (analyzed.resolved) {
    +        analyzed
    +      } else {
    +        // Only resolve the lowest plan that is not resolved by outer 
plan, otherwise it could be
    +        // resolved by itself
    +        val resolvedByOuter = analyzed transformDown {
    --- End diff --
    
    Yeah, that is fair.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to