vladimirg-db commented on code in PR #50548:
URL: https://github.com/apache/spark/pull/50548#discussion_r2036821317


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -199,21 +199,27 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
 
   // Resolves `UnresolvedAttribute` to `OuterReference`.
   protected def resolveOuterRef(e: Expression): Expression = {
-    val outerPlan = AnalysisContext.get.outerPlan
-    if (outerPlan.isEmpty) return e
+    val outerPlanContext = AnalysisContext.get.outerPlans
+    if (outerPlanContext.isEmpty) return e
 
     def resolve(nameParts: Seq[String]): Option[Expression] = try {
-      outerPlan.get match {
-        // Subqueries in UnresolvedHaving can host grouping expressions and 
aggregate functions.
-        // We should resolve columns with `agg.output` and the rule 
`ResolveAggregateFunctions` will
-        // push them down to Aggregate later. This is similar to what we do in 
`resolveColumns`.
-        case u @ UnresolvedHaving(_, agg: Aggregate) =>
-          agg.resolveChildren(nameParts, conf.resolver)
-            .orElse(u.resolveChildren(nameParts, conf.resolver))
-            .map(wrapOuterReference)
-        case other =>
-          other.resolveChildren(nameParts, 
conf.resolver).map(wrapOuterReference)
+      val outerPlans = outerPlanContext.get
+      val resolvedExpressions = outerPlans.flatMap {

Review Comment:
   Shouldn't the resolution be backwards? From the lower outer plan to the 
upper. As far as I can see, the lower outer plan is the last one.



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to