adonis0147 commented on code in PR #12129:
URL: https://github.com/apache/doris/pull/12129#discussion_r959638781


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Alias.java:
##########
@@ -49,7 +49,7 @@ public Alias(Expression child, String name) {
     }
 
     @VisibleForTesting
-    Alias(ExprId exprId, Expression child, String name) {
+    public Alias(ExprId exprId, Expression child, String name) {

Review Comment:
   We should make this function `public` here, due to the package of 
`org.apache.doris.nereids.parser.HavingCluaseTest` is different from the one of 
`org.apache.doris.nereids.trees.expressions.Alias`



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -123,11 +126,23 @@ public List<Rule> buildRules() {
                     return new LogicalSort<>(sortItemList, sort.child());
                 })
             ),
-
+            RuleType.BINDING_HAVING_SLOT.build(
+                logicalHaving(logicalAggregate()).thenApply(ctx -> {
+                    LogicalHaving<LogicalAggregate<GroupPlan>> having = 
ctx.root;
+                    LogicalAggregate<GroupPlan> aggregate = having.child();
+                    Set<Slot> boundSlots = Stream.concat(Stream.of(aggregate), 
aggregate.children().stream())
+                            .flatMap(plan -> plan.getOutput().stream())
+                            .collect(Collectors.toSet());
+                    Expression boundPredicates = new SlotBinder(
+                            toScope(new ArrayList<>(boundSlots)), having, 
ctx.cascadesContext

Review Comment:
   We should deduplicate the slots, otherwise the binding process will fail due 
to the ambiguous slots exist.
   
   I added a comment.



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