cloud-fan commented on a change in pull request #31913:
URL: https://github.com/apache/spark/pull/31913#discussion_r611684476
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -655,12 +666,76 @@ case class Aggregate(
}
}
+ private def expandGroupingReferences(e: Expression): Expression = {
+ e match {
+ case _: AggregateExpression => e
+ case _ if PythonUDF.isGroupedAggPandasUDF(e) => e
+ case g: GroupingExprRef => groupingExpressions(g.ordinal)
+ case _ => e.mapChildren(expandGroupingReferences)
+ }
+ }
+
+ lazy val aggregateExpressionsWithoutGroupingRefs = {
+
aggregateExpressions.map(expandGroupingReferences(_).asInstanceOf[NamedExpression])
+ }
+
override lazy val validConstraints: ExpressionSet = {
val nonAgg =
aggregateExpressions.filter(_.find(_.isInstanceOf[AggregateExpression]).isEmpty)
getAllValidConstraints(nonAgg)
}
}
+object Aggregate {
+ private def collectComplexGroupingExpressions(groupingExpressions:
Seq[Expression]) = {
+ groupingExpressions.zipWithIndex
+ .foldLeft(mutable.Map.empty[Expression, (Expression, Int)]) {
+ case (m, (ge, i)) =>
+ if (ge.deterministic && !ge.foldable && ge.children.nonEmpty &&
Review comment:
IIRC the analyzer enforces that `groupingExpressions` are deterministic?
And why do we exclude `Attribute` to be `GroupingExprRef`?
--
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]