englefly commented on code in PR #15240:
URL: https://github.com/apache/doris/pull/15240#discussion_r1059846750


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -194,11 +195,55 @@ public List<Rule> buildRules() {
 
                     // The columns referenced in group by are first obtained 
from the child's output,
                     // and then from the node's output
+                    Set<String> duplicatedSlotNames = new HashSet<>();
                     Map<String, Expression> childOutputsToExpr = 
agg.child().getOutput().stream()
-                            .collect(Collectors.toMap(Slot::getName, 
Slot::toSlot, (oldExpr, newExpr) -> oldExpr));
+                            .collect(Collectors.toMap(Slot::getName, 
Slot::toSlot,
+                                    (oldExpr, newExpr) -> {
+                                        duplicatedSlotNames.add(((Slot) 
oldExpr).getName());
+                                        return oldExpr;
+                                }));

Review Comment:
   groupByKey绑定到output 的alias 有问题,会导致NormalizeAggregate的逻辑出错。
   `SELECT SUM(t1.c) FROM t1 JOIN t2 GROUP BY t1.a;` 这个sql 现在的逻辑执行也没有问题。
   `replacedGroupBy={t1.a}`, 在L265 会绑定到join的output



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