Search in sources :

Example 1 with Ordering

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;
}
Also used : SortOrder(com.facebook.presto.common.block.SortOrder) Session(com.facebook.presto.Session) Maps(com.google.common.collect.Maps) Domain(com.facebook.presto.common.predicate.Domain) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) List(java.util.List) Ordering(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.Ordering) ColumnHandle(com.facebook.presto.spi.ColumnHandle) Symbol(com.facebook.presto.sql.planner.Symbol) Map(java.util.Map) Optional(java.util.Optional) TableHandle(com.facebook.presto.spi.TableHandle) OrderingScheme(com.facebook.presto.spi.plan.OrderingScheme) Metadata(com.facebook.presto.metadata.Metadata) Iterators.getOnlyElement(com.google.common.collect.Iterators.getOnlyElement) Symbol(com.facebook.presto.sql.planner.Symbol) Ordering(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.Ordering) SortOrder(com.facebook.presto.common.block.SortOrder)

Aggregations

Session (com.facebook.presto.Session)1 SortOrder (com.facebook.presto.common.block.SortOrder)1 Domain (com.facebook.presto.common.predicate.Domain)1 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)1 Metadata (com.facebook.presto.metadata.Metadata)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 TableHandle (com.facebook.presto.spi.TableHandle)1 OrderingScheme (com.facebook.presto.spi.plan.OrderingScheme)1 Symbol (com.facebook.presto.sql.planner.Symbol)1 Ordering (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.Ordering)1 Iterators.getOnlyElement (com.google.common.collect.Iterators.getOnlyElement)1 Maps (com.google.common.collect.Maps)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1