Skip to content

Commit

Permalink
Fix bad merge in AddExchanges
Browse files Browse the repository at this point in the history
Changes in commit 71a8393 mistakenly
got merged into visitLimit instead of visitSort.
  • Loading branch information
wenleix committed Mar 22, 2017
1 parent 71a8393 commit d4e08bf
Showing 1 changed file with 14 additions and 14 deletions.
Expand Up @@ -456,6 +456,20 @@ public PlanWithProperties visitSort(SortNode node, Context context)
gatheringExchange(idAllocator.getNextId(), REMOTE, child.getNode()),
child.getProperties());
}
else {
// current plan so far is single node, so local properties are effectively global properties
// skip the SortNode if the local properties guarantee ordering on Sort keys
// TODO: This should be extracted as a separate optimizer once the planner is able to reason about the ordering of each operator
List<LocalProperty<Symbol>> desiredProperties = new ArrayList<>();
for (Symbol symbol : node.getOrderBy()) {
desiredProperties.add(new SortingProperty<>(symbol, node.getOrderings().get(symbol)));
}

if (LocalProperties.match(child.getProperties().getLocalProperties(), desiredProperties).stream()
.noneMatch(Optional::isPresent)) {
return child;
}
}

return rebaseAndDeriveProperties(node, child);
}
Expand All @@ -474,20 +488,6 @@ public PlanWithProperties visitLimit(LimitNode node, Context context)
gatheringExchange(idAllocator.getNextId(), REMOTE, child.getNode()),
child.getProperties());
}
else {
// current plan so far is single node, so local properties are effectively global properties
// skip the SortNode if the local properties guarantee ordering on Sort keys
// TODO: This should be extracted as a separate optimizer once the planner is able to reason about the ordering of each operator
List<LocalProperty<Symbol>> desiredProperties = new ArrayList<>();
for (Symbol symbol : node.getOrderBy()) {
desiredProperties.add(new SortingProperty<>(symbol, node.getOrderings().get(symbol)));
}

if (LocalProperties.match(child.getProperties().getLocalProperties(), desiredProperties).stream()
.noneMatch(Optional::isPresent)) {
return child;
}
}

return rebaseAndDeriveProperties(node, child);
}
Expand Down

0 comments on commit d4e08bf

Please sign in to comment.