morrySnow commented on code in PR #36207: URL: https://github.com/apache/doris/pull/36207#discussion_r1637422562
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java: ########## @@ -460,4 +463,25 @@ public Expression visitWindow(WindowExpression windowExpression, Map<Slot, Alias return hasNewChildren ? windowExpression.withChildren(newChildren) : windowExpression; } } + + private List<NamedExpression> getExprIdUnchangedNormalizedAggOutput(List<NamedExpression> normalizedAggOutput, + List<NamedExpression> originalAggOutput) { + Builder<NamedExpression> builder = new ImmutableList.Builder<>(); + for (int i = 0; i < originalAggOutput.size(); i++) { + NamedExpression e = normalizedAggOutput.get(i); + // process Expression like Alias(SlotReference#0)#0 + if (e instanceof Alias && e.child(0) instanceof SlotReference) { + SlotReference slotReference = (SlotReference) e.child(0); + if (slotReference.getExprId().equals(e.getExprId())) { + e = slotReference; + } + } + // Make the output ExprId unchanged + if (!e.getExprId().equals(originalAggOutput.get(i).getExprId())) { + e = new Alias(originalAggOutput.get(i).getExprId(), e, originalAggOutput.get(i).getName()); + } Review Comment: why changed in `normalizeToUseSlotRef`, could we ensure it not changed in `normalizeToUseSlotRef`? -- 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