EmilyMatt commented on code in PR #1670:
URL: https://github.com/apache/datafusion-comet/pull/1670#discussion_r2062485241
##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -430,55 +430,43 @@ class CometSparkSessionExtensions
op,
CometExpandExec(_, op, op.output, op.projections, op.child,
SerializedPlan(None)))
+ // When Comet shuffle is disabled, we don't want to transform the
HashAggregate
+ // to CometHashAggregate. Otherwise, we probably get partial Comet
aggregation
+ // and final Spark aggregation.
case op: BaseAggregateExec
if op.isInstanceOf[HashAggregateExec] ||
op.isInstanceOf[ObjectHashAggregateExec] &&
- // When Comet shuffle is disabled, we don't want to transform
the HashAggregate
- // to CometHashAggregate. Otherwise, we probably get partial
Comet aggregation
- // and final Spark aggregation.
isCometShuffleEnabled(conf) =>
- val groupingExprs = op.groupingExpressions
- val aggExprs = op.aggregateExpressions
- val resultExpressions = op.resultExpressions
- val child = op.child
- val modes = aggExprs.map(_.mode).distinct
-
- if (modes.nonEmpty && modes.size != 1) {
- // This shouldn't happen as all aggregation expressions should
share the same mode.
- // Fallback to Spark nevertheless here.
+ val modes = op.aggregateExpressions.map(_.mode).distinct
+ // In distinct aggregates there can be a combination of modes
+ val multiMode = modes.size > 1
+ // For a final mode HashAggregate, we only need to transform the
HashAggregate
+ // if there is Comet partial aggregation.
+ val sparkFinalMode = modes.contains(Final) &&
findCometPartialAgg(op.child).isEmpty
Review Comment:
(There was never an intended check for "Is the first one Final", because
that has no specific implication, the check was always "If there is only one,
and that one is a Final")
--
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]