morrySnow commented on code in PR #34196:
URL: https://github.com/apache/doris/pull/34196#discussion_r1590634418


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java:
##########
@@ -117,19 +117,29 @@ private void checkGroupingSetsSize(LogicalRepeat<Plan> 
repeat) {
     }
 
     private LogicalAggregate<Plan> normalizeRepeat(LogicalRepeat<Plan> repeat) 
{
-        Set<Expression> needToSlots = collectNeedToSlotExpressions(repeat);
-        NormalizeToSlotContext context = buildContext(repeat, needToSlots);
+        Set<Expression> needToSlotsGroupingExpr = 
collectNeedToSlotGroupingExpr(repeat);
+        NormalizeToSlotContext groupingExprContext = buildContext(repeat, 
needToSlotsGroupingExpr);
+        Map<Expression, NormalizeToSlotTriplet> groupingExprMap = 
groupingExprContext.getNormalizeToSlotMap();
+        Set<Alias> existsAlias = getExistsAlias(repeat, groupingExprMap);
+        Set<Expression> needToSlotsArgs = 
collectNeedToSlotArgsOfGroupingScalarFuncAndAggFunc(repeat);
+        NormalizeToSlotContext argsContext = 
NormalizeToSlotContext.buildContext(existsAlias, needToSlotsArgs);
 
         // normalize grouping sets to List<List<Slot>>
         List<List<Slot>> normalizedGroupingSets = repeat.getGroupingSets()
                 .stream()
-                .map(groupingSet -> (List<Slot>) (List) 
context.normalizeToUseSlotRef(groupingSet))
+                .map(groupingSet -> (List<Slot>) (List) 
groupingExprContext.normalizeToUseSlotRef(groupingSet))
                 .collect(ImmutableList.toImmutableList());
 
-        // replace the arguments of grouping scalar function to virtual slots
-        // replace some complex expression to slot, e.g. `a + 1`
-        List<NamedExpression> normalizedAggOutput = 
context.normalizeToUseSlotRef(
-                        repeat.getOutputExpressions(), 
this::normalizeGroupingScalarFunction);
+        // use argsContext
+        // rewrite the arguments of grouping scalar function to slots
+        // rewrite grouping scalar function to virtual slots
+        // rewrite the arguments of agg function to slots
+        List<NamedExpression> normalizedAggOutput = 
repeat.getOutputExpressions().stream()

Review Comment:
   could we replace all stream api by for loop?



-- 
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: commits-unsubscr...@doris.apache.org

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


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

Reply via email to