EmilyMatt commented on code in PR #1670:
URL: https://github.com/apache/datafusion-comet/pull/1670#discussion_r2062480644


##########
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:
   Indeed, but then `multiMode` is true, and we return op anyway, since we 
don't support multiple modes atm, which is the intended behaviour.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to