morrySnow commented on code in PR #37644: URL: https://github.com/apache/doris/pull/37644#discussion_r1674194865
########## fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java: ########## @@ -204,7 +204,8 @@ public class Rewriter extends AbstractBatchJobExecutor { * TODO: group these rules to make sure the result plan is what we expected. */ new CorrelateApplyToUnCorrelateApply(), - new ApplyToJoin() + new ApplyToJoin(), + new NormalizeAggregate() Review Comment: why need this normalize aggregate? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnCorrelatedApplyAggregateFilter.java: ########## @@ -97,10 +100,19 @@ public List<Rule> buildRules() { // pull up correlated filter into apply node List<NamedExpression> newAggOutput = new ArrayList<>(agg.getOutputExpressions()); List<Expression> newGroupby = - Utils.getCorrelatedSlots(correlatedPredicate, apply.getCorrelationSlot()); + Utils.getUnCorrelatedExprs(correlatedPredicate, apply.getCorrelationSlot()); newGroupby.addAll(agg.getGroupByExpressions()); - newAggOutput.addAll(newGroupby.stream().map(NamedExpression.class::cast) - .collect(ImmutableList.toImmutableList())); + Map<Expression, Slot> unCorrelatedExprToSlot = Maps.newHashMap(); + newAggOutput.addAll(newGroupby.stream().map(expression -> { + if (expression instanceof Slot) { + return (NamedExpression) expression; + } else { + Alias alias = new Alias(expression); + unCorrelatedExprToSlot.put(expression, alias.toSlot()); + return alias; + } + }).collect(ImmutableList.toImmutableList())); Review Comment: do not use stream api -- 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