morrySnow commented on code in PR #15646:
URL: https://github.com/apache/doris/pull/15646#discussion_r1064145194
##########
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:
remove useless comments
##########
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);
Review Comment:
remove useless comments
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -540,10 +560,17 @@ private <E extends Expression> E bind(E expr, List<Plan>
inputs, Plan plan, Casc
private class SlotBinder extends SubExprAnalyzer {
private final Plan plan;
+ //strict = true: bind slot including its qualifier
+ private boolean strict;
Review Comment:
unuse var
##########
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();
Review Comment:
should we also update BINDING_SORT_SLOT rule on pattern
`logicalSort(logicalHaving(logicalProject()))`
##########
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)),
Review Comment:
remove `strict` in var's name
##########
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:
ditto
--
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]