924060929 commented on code in PR #51086: URL: https://github.com/apache/doris/pull/51086#discussion_r2097610577
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SubqueryToApply.java: ########## @@ -434,8 +434,14 @@ private Pair<LogicalPlan, Optional<Expression>> addApply(SubqueryExpr subquery, Preconditions.checkState(logicalProject.getOutputs().size() == 1, "Scalar subuqery's should only output 1 column"); Slot aggSlot = agg.toSlot(); - replaceMap.put(aggSlot, new Alias(new Nvl(aggSlot, - notNullableAggFunc.resultForEmptyInput()))); + // we should keep the exprId, so that the parent plan can bind this slot + replaceMap.put(aggSlot, + new Alias( + aggSlot.getExprId(), Review Comment: I think this `generate same exprid for two different slot in one plan` is not a problem, ensure different exprId maybe high cost, because it maybe exists under multiple level children, for example this is the wrong case, you should find all `#382` which under the first LogicalApply to replace ``` LogicalProject(projects=[count(*)#382]) | LogicalApply | LogicalProject(projects=[ifnull(count(*)#382, 0) AS `ifnull(count(*), 0)`#693]) | LogicalApply | LogicalAggregate(groupByExpr=[], outputExpr=[count(*) AS `count(*)`#382]) | .... ``` -- 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