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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -354,13 +355,32 @@ public List<Rule> buildRules() {
             RuleType.BINDING_SORT_SLOT.build(
                 
logicalSort(logicalProject()).when(Plan::canBind).thenApply(ctx -> {
                     LogicalSort<LogicalProject<GroupPlan>> sort = ctx.root;
+                    Set<Slot> orderSlots = Sets.newHashSet();
+                    sort.getOrderKeys().stream()
+                            .forEach(orderKey ->
+                                
orderSlots.addAll(orderKey.getExpr().getInputSlots()));
+                    Set<Slot> projectOutput = sort.child().getOutputSet();
+                    SlotBinder strictBinderOnProject = new 
SlotBinder(toScope(Lists.newArrayList(projectOutput)),
+                            sort, true, ctx.cascadesContext);
+                    //SlotBinder looseBinderOnProject = new 
SlotBinder(toScope(Lists.newArrayList(projectOutput)),
+                    //        sort, false, ctx.cascadesContext);
+
+                    Set<Slot> projectChildrenOutput = 
sort.child().children().stream()
+                            .flatMap(plan -> plan.getOutputSet().stream())
+                            .collect(Collectors.toSet());
+                    SlotBinder strictBinderOnProjectChild = new SlotBinder(
+                            toScope(Lists.newArrayList(projectChildrenOutput)),
+                            sort, true, ctx.cascadesContext);
+                    //SlotBinder looseBinderOnProjectChild = new SlotBinder(
+                    //        
toScope(Lists.newArrayList(projectChildrenOutput)),
+                    //        sort, false, ctx.cascadesContext);
                     List<OrderKey> sortItemList = sort.getOrderKeys()
                             .stream()
                             .map(orderKey -> {
-                                Expression item = bind(orderKey.getExpr(), 
sort.children(), sort, ctx.cascadesContext);
-                                if (item.containsType(UnboundSlot.class)) {
-                                    item = bind(item, sort.child().children(), 
sort, ctx.cascadesContext);
-                                }
+                                Expression item = 
strictBinderOnProject.bind(orderKey.getExpr());
+                                item = strictBinderOnProjectChild.bind(item);
+                                //item = looseBinderOnProjectChild.bind(item);
+                                //item = looseBinderOnProject.bind(item);

Review Comment:
   done



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -354,13 +355,32 @@ public List<Rule> buildRules() {
             RuleType.BINDING_SORT_SLOT.build(
                 
logicalSort(logicalProject()).when(Plan::canBind).thenApply(ctx -> {
                     LogicalSort<LogicalProject<GroupPlan>> sort = ctx.root;
+                    Set<Slot> orderSlots = Sets.newHashSet();
+                    sort.getOrderKeys().stream()
+                            .forEach(orderKey ->
+                                
orderSlots.addAll(orderKey.getExpr().getInputSlots()));
+                    Set<Slot> projectOutput = sort.child().getOutputSet();
+                    SlotBinder strictBinderOnProject = new 
SlotBinder(toScope(Lists.newArrayList(projectOutput)),
+                            sort, true, ctx.cascadesContext);
+                    //SlotBinder looseBinderOnProject = new 
SlotBinder(toScope(Lists.newArrayList(projectOutput)),
+                    //        sort, false, ctx.cascadesContext);
+
+                    Set<Slot> projectChildrenOutput = 
sort.child().children().stream()
+                            .flatMap(plan -> plan.getOutputSet().stream())
+                            .collect(Collectors.toSet());
+                    SlotBinder strictBinderOnProjectChild = new SlotBinder(
+                            toScope(Lists.newArrayList(projectChildrenOutput)),
+                            sort, true, ctx.cascadesContext);
+                    //SlotBinder looseBinderOnProjectChild = new SlotBinder(
+                    //        
toScope(Lists.newArrayList(projectChildrenOutput)),
+                    //        sort, false, ctx.cascadesContext);

Review Comment:
   done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to