Search in sources :

Example 11 with LimitNode

use of io.trino.sql.planner.plan.LimitNode in project trino by trinodb.

the class TestCostCalculator method testLimit.

@Test
public void testLimit() {
    TableScanNode ts1 = tableScan("ts1", "orderkey");
    LimitNode limit = new LimitNode(new PlanNodeId("limit"), ts1, 5, false);
    Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.of("ts1", statsEstimate(ts1, 4000), "limit", // 5 * average row size
    statsEstimate(ts1, 40));
    Map<String, PlanCostEstimate> costs = ImmutableMap.of("ts1", cpuCost(1000));
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT);
    // Do not estimate cost other than CPU for limit node.
    assertCost(limit, costs, stats, types).cpu(// 1000 + (is null boolean array) + 40
    1045).memory(0).network(0);
    assertCostEstimatedExchanges(limit, costs, stats, types).cpu(1045).memory(0).network(0);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) Type(io.trino.spi.type.Type) TableScanNode(io.trino.sql.planner.plan.TableScanNode) LimitNode(io.trino.sql.planner.plan.LimitNode) Test(org.testng.annotations.Test)

Example 12 with LimitNode

use of io.trino.sql.planner.plan.LimitNode in project trino by trinodb.

the class TestEffectivePredicateExtractor method testLimit.

@Test
public void testLimit() {
    PlanNode node = new LimitNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), 1, false);
    Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
    // Pass through
    assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) LimitNode(io.trino.sql.planner.plan.LimitNode) InListExpression(io.trino.sql.tree.InListExpression) NotExpression(io.trino.sql.tree.NotExpression) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) Expression(io.trino.sql.tree.Expression) Test(org.testng.annotations.Test)

Aggregations

LimitNode (io.trino.sql.planner.plan.LimitNode)12 PlanNode (io.trino.sql.planner.plan.PlanNode)6 Symbol (io.trino.sql.planner.Symbol)5 ProjectNode (io.trino.sql.planner.plan.ProjectNode)4 Expression (io.trino.sql.tree.Expression)4 ImmutableList (com.google.common.collect.ImmutableList)3 Assignments (io.trino.sql.planner.plan.Assignments)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Captures (io.trino.matching.Captures)2 Pattern (io.trino.matching.Pattern)2 TypeSignatureTranslator.toSqlType (io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType)2 OrderingScheme (io.trino.sql.planner.OrderingScheme)2 Rule (io.trino.sql.planner.iterative.Rule)2 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Test (org.testng.annotations.Test)2 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1