ulysses-you commented on a change in pull request #30029:
URL: https://github.com/apache/spark/pull/30029#discussion_r504509715



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -646,9 +646,9 @@ class Analyzer(
         // Since the exprId of extraAggExprs will be changed in the 
constructed aggregate, and the
         // aggregateExpressions keeps the input order. So here we build an 
exprMap to resolve the
         // condition again.
-        val exprMap = extraAggExprs.zip(
-          newChild.asInstanceOf[Aggregate].aggregateExpressions.takeRight(
-            extraAggExprs.length)).toMap
+        // We also add the original aggregateExpressions in Map to avoid 
extraAggExprs is empty.

Review comment:
       If we resolved the having condition but extraAggExprs is empty, that 
means the resolution is in original aggregateExpressions.
   
   We need use original aggregateExpressions mapping having condition 
NamedExpression to the new since grouping sets constructAggregate will build 
the new alias for it.




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

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to