Search in sources :

Example 1 with TopNRankingNumberNode

use of io.prestosql.sql.planner.plan.TopNRankingNumberNode in project hetu-core by openlookeng.

the class TopNRankingNumberMatcher method detailMatches.

@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
    checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
    TopNRankingNumberNode topNRankingNumberNode = (TopNRankingNumberNode) node;
    if (specification.isPresent()) {
        WindowNode.Specification expected = specification.get().getExpectedValue(symbolAliases);
        if (!expected.equals(topNRankingNumberNode.getSpecification())) {
            return NO_MATCH;
        }
    }
    if (rowNumberSymbol.isPresent()) {
        Symbol expected = rowNumberSymbol.get().toSymbol(symbolAliases);
        if (!expected.equals(topNRankingNumberNode.getRowNumberSymbol())) {
            return NO_MATCH;
        }
    }
    if (maxRowCountPerPartition.isPresent()) {
        if (!maxRowCountPerPartition.get().equals(topNRankingNumberNode.getMaxRowCountPerPartition())) {
            return NO_MATCH;
        }
    }
    if (partial.isPresent()) {
        if (!partial.get().equals(topNRankingNumberNode.isPartial())) {
            return NO_MATCH;
        }
    }
    if (hashSymbol.isPresent()) {
        Optional<Symbol> expected = hashSymbol.get().map(alias -> alias.toSymbol(symbolAliases));
        if (!expected.equals(topNRankingNumberNode.getHashSymbol())) {
            return NO_MATCH;
        }
    }
    return match();
}
Also used : TopNRankingNumberNode(io.prestosql.sql.planner.plan.TopNRankingNumberNode) WindowNode(io.prestosql.spi.plan.WindowNode) Symbol(io.prestosql.spi.plan.Symbol)

Aggregations

Symbol (io.prestosql.spi.plan.Symbol)1 WindowNode (io.prestosql.spi.plan.WindowNode)1 TopNRankingNumberNode (io.prestosql.sql.planner.plan.TopNRankingNumberNode)1