use of com.facebook.presto.sql.planner.assertions.PlanMatchPattern.Ordering in project presto by prestodb.
the class Util method orderingSchemeMatches.
static boolean orderingSchemeMatches(List<Ordering> expectedOrderBy, OrderingScheme orderingScheme, SymbolAliases symbolAliases) {
if (expectedOrderBy.size() != orderingScheme.getOrderByVariables().size()) {
return false;
}
for (int i = 0; i < expectedOrderBy.size(); ++i) {
Ordering ordering = expectedOrderBy.get(i);
Symbol symbol = Symbol.from(symbolAliases.get(ordering.getField()));
if (!symbol.equals(new Symbol(orderingScheme.getOrderByVariables().get(i).getName()))) {
return false;
}
SortOrder sortOrder = getOnlyElement(Maps.filterKeys(orderingScheme.getOrderingsMap(), variable -> variable.getName().equals(symbol.getName())).values().iterator());
if (!ordering.getSortOrder().equals(sortOrder)) {
return false;
}
}
return true;
}
Aggregations