cloud-fan commented on a change in pull request #31913:
URL: https://github.com/apache/spark/pull/31913#discussion_r612558996



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -793,6 +817,56 @@ case class Aggregate(
     copy(child = newChild)
 }
 
+object Aggregate {
+  private def collectComplexGroupingExpressions(groupingExpressions: 
Seq[Expression]) = {
+    groupingExpressions.zipWithIndex
+      .foldLeft(mutable.Map.empty[Expression, (Expression, Int)]) {
+        case (m, (ge, i)) =>
+          if (!ge.foldable && ge.children.nonEmpty && 
!m.contains(ge.canonicalized)) {
+            m += ge.canonicalized -> (ge, i)
+          }
+          m
+      }
+  }
+
+  private def insertGroupingReferences(
+      aggregateExpressions: Seq[NamedExpression],
+      groupingExpressions: collection.Map[Expression, (Expression, Int)]): 
Seq[NamedExpression] = {
+    def insertGroupingExprRefs(e: Expression): Expression = {
+      e match {
+        case _ if !e.deterministic => e
+        case _: AggregateExpression => e
+        case _ if PythonUDF.isGroupedAggPandasUDF(e) => e

Review comment:
       Can we add a util function in `object AggregateExpression` to check if 
an expression is an aggregate function? I've seen this pattern many times to 
check aggregate functions.




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