feiniaofeiafei commented on code in PR #63690:
URL: https://github.com/apache/doris/pull/63690#discussion_r3402061885


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/eageraggregation/PushDownAggregation.java:
##########
@@ -255,18 +256,18 @@ public Plan visitLogicalAggregate(LogicalAggregate<? 
extends Plan> agg, JobConte
                         Map<Expression, Expression> replaceMap = new 
HashMap<>();
                         List<AggregateFunction> relatedAggFunc = 
aggFunctionsForOutputExpressions.get(ne);
                         for (AggregateFunction func : relatedAggFunc) {
-                            Slot pushedDownSlot = 
pushDownContext.getAliasMap().get(func).toSlot();
+                            Alias pushedAlias = 
pushDownContext.getAliasMap().get(func);
+                            ExprId pushId = pushedAlias.getExprId();
+                            if (!state.hasAggFuncOutput(pushId)) {
+                                continue;
+                            }
+                            Expression value = 
state.getPushedAggFuncSlot(pushId);
                             if (func instanceof Count) {
-                                // For count(A), after pushdown we have 
count(A) as x,
-                                // and the top agg should use sum(x) instead 
of count(x).
-                                // Wrap with ifnull(..., 0) because COUNT 
never returns NULL,
-                                // but after pushdown across an outer join, 
the intermediate count
-                                // slot can be NULL (null-extended), making 
sum(NULL) = NULL.
-                                Function rollUpFunc = ((RollUpTrait) 
func).constructRollUp(pushedDownSlot);
-                                replaceMap.put(func, new Nvl(rollUpFunc, new 
BigIntLiteral(0)));
+                                replaceMap.put(func, new Sum0(value));
+                            } else if (func instanceof Max || func instanceof 
Min) {
+                                replaceMap.put(func.child(0), value);
                             } else if (func.arity() > 0) {
-                                // For sum/max/min, replace the child 
expression with the pushed down slot
-                                replaceMap.put(func.child(0), pushedDownSlot);
+                                replaceMap.put(func.child(0), value);

Review Comment:
   fixed



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

Reply via email to