cloud-fan commented on code in PR #39269:
URL: https://github.com/apache/spark/pull/39269#discussion_r1058718270
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveLateralColumnAliasReference.scala:
##########
@@ -168,19 +168,18 @@ object ResolveLateralColumnAliasReference extends
Rule[LogicalPlan] {
&&
aggregateExpressions.exists(_.containsPattern(LATERAL_COLUMN_ALIAS_REFERENCE))
=>
// Check if current Aggregate is eligible to lift up with Project:
the aggregate
- // expression only contains: 1) aggregate functions, 2) grouping
expressions, 3) lateral
- // column alias reference or 4) literals.
+ // expression only contains: 1) aggregate functions, 2) grouping
expressions, 3) leaf
+ // expressions excluding attributes not in grouping expressions
// This check is to prevent unnecessary transformation on invalid
plan, to guarantee it
// throws the same exception. For example, cases like non-aggregate
expressions not
// in group by, once transformed, will throw a different exception:
missing input.
def eligibleToLiftUp(exp: Expression): Boolean = {
exp match {
case e if AggregateExpression.isAggregate(e) => true
- case e if groupingExpressions.exists(_.semanticEquals(e)) => true
- case _: Literal | _: LateralColumnAliasReference => true
+ case e: Attribute if
!groupingExpressions.exists(_.semanticEquals(e)) => false
Review Comment:
can we move it closer to `case e if
groupingExpressions.exists(_.semanticEquals(e)) => true`?
--
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]