cloud-fan commented on code in PR #37825:
URL: https://github.com/apache/spark/pull/37825#discussion_r979582134
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteDistinctAggregates.scala:
##########
@@ -218,9 +218,16 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan]
{
val aggExpressions = collectAggregateExprs(a)
val distinctAggs = aggExpressions.filter(_.isDistinct)
+ val funcChildren = distinctAggs.flatMap { e =>
+ e.aggregateFunction.children.filter(!_.foldable)
+ }
+ val funcChildrenLookup = funcChildren.map { e =>
+ (e, funcChildren.find(fc => e.semanticEquals(fc)).getOrElse(e))
+ }.toMap
+
// Extract distinct aggregate expressions.
val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e =>
Review Comment:
Shall we return `ExpressionSet` in all branches so that the key type here is
`ExpressionSet`? Then it's pretty easy to get back the original expressions, by
`ExpressionSet.toSeq`.
--
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]