viirya commented on code in PR #38888:
URL: https://github.com/apache/spark/pull/38888#discussion_r1055210391
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -1505,14 +1543,25 @@ class Analyzer(override val catalogManager:
CatalogManager)
}
val resolvedGroupingExprs = a.groupingExpressions
- .map(resolveExpressionByPlanChildren(_, planForResolve))
+ .map(resolveExpressionByPlanChildren(_, planForResolve, allowOuter =
true))
.map(trimTopLevelGetStructFieldAlias)
- val resolvedAggExprs = a.aggregateExpressions
- .map(resolveExpressionByPlanChildren(_, planForResolve))
- .map(_.asInstanceOf[NamedExpression])
-
- a.copy(resolvedGroupingExprs, resolvedAggExprs, a.child)
+ val resolvedAggExprsNoOuter = a.aggregateExpressions
+ .map(resolveExpressionByPlanChildren(_, planForResolve, allowOuter =
false))
+ // Aggregate supports Lateral column alias, which has higher priority
than outer reference.
+ val resolvedAggExprsWithLCA =
resolveLateralColumnAlias(resolvedAggExprsNoOuter)
+ val resolvedAggExprsWithOuter =
resolvedAggExprsWithLCA.map(resolveOuterRef)
+ .map(_.asInstanceOf[NamedExpression])
+ a.copy(resolvedGroupingExprs, resolvedAggExprsWithOuter, a.child)
+
+ // Special case for Project as it supports literal column alias.
Review Comment:
```suggestion
// Special case for Project as it supports Lateral column alias.
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]