You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2023/01/02 06:08:24 UTC

[GitHub] [doris] englefly commented on a diff in pull request #15240: [fix](nereids) binding priority in agg-sort, having, group_by_key

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-unsubscribe@doris.apache.org

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


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