Search in sources :

Example 1 with SortNode

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

the class SortMatcher 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());
    SortNode sortNode = (SortNode) node;
    if (!orderingSchemeMatches(orderBy, sortNode.getOrderingScheme(), symbolAliases)) {
        return NO_MATCH;
    }
    return MatchResult.match();
}
Also used : SortNode(io.prestosql.sql.planner.plan.SortNode)

Example 2 with SortNode

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

the class MergeLimitOverProjectWithSort method apply.

@Override
public Result apply(LimitNode parent, Captures captures, Context context) {
    ProjectNode project = captures.get(PROJECT);
    SortNode sort = captures.get(SORT);
    return Result.ofPlanNode(project.replaceChildren(ImmutableList.of(new TopNNode(parent.getId(), sort.getSource(), parent.getCount(), sort.getOrderingScheme(), parent.isPartial() ? PARTIAL : SINGLE))));
}
Also used : SortNode(io.prestosql.sql.planner.plan.SortNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) TopNNode(io.prestosql.spi.plan.TopNNode)

Example 3 with SortNode

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

the class TestEffectivePredicateExtractor method testSort.

@Test
public void testSort() {
    PlanNode node = new SortNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), new OrderingScheme(ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST)), false);
    Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
    // Pass through
    assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
Also used : OrderingScheme(io.prestosql.spi.plan.OrderingScheme) PlanNode(io.prestosql.spi.plan.PlanNode) SortNode(io.prestosql.sql.planner.plan.SortNode) CallExpression(io.prestosql.spi.relation.CallExpression) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) InListExpression(io.prestosql.sql.tree.InListExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Expression(io.prestosql.sql.tree.Expression) Test(org.testng.annotations.Test)

Aggregations

SortNode (io.prestosql.sql.planner.plan.SortNode)3 OrderingScheme (io.prestosql.spi.plan.OrderingScheme)1 PlanNode (io.prestosql.spi.plan.PlanNode)1 ProjectNode (io.prestosql.spi.plan.ProjectNode)1 TopNNode (io.prestosql.spi.plan.TopNNode)1 CallExpression (io.prestosql.spi.relation.CallExpression)1 RowExpression (io.prestosql.spi.relation.RowExpression)1 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)1 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)1 Expression (io.prestosql.sql.tree.Expression)1 InListExpression (io.prestosql.sql.tree.InListExpression)1 Test (org.testng.annotations.Test)1