Search in sources :

Example 21 with TableScanNode

use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.

the class TestCostCalculator method testProject.

@Test
public void testProject() {
    TableScanNode tableScan = tableScan("ts", "orderkey");
    PlanNode project = project("project", tableScan, "string", new Cast(new SymbolReference("orderkey"), "STRING"));
    Map<String, PlanCostEstimate> costs = ImmutableMap.of("ts", cpuCost(1000));
    Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.of("project", statsEstimate(project, 4000), "ts", statsEstimate(tableScan, 1000));
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "string", VARCHAR);
    assertCost(project, costs, stats, types).cpu(1000 + 4000 * OFFSET_AND_IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostEstimatedExchanges(project, costs, stats, types).cpu(1000 + 4000 * OFFSET_AND_IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostFragmentedPlan(project, costs, stats, types).cpu(1000 + 4000 * OFFSET_AND_IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostHasUnknownComponentsForUnknownStats(project, types);
}
Also used : Cast(io.prestosql.sql.tree.Cast) Type(io.prestosql.spi.type.Type) PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) SymbolReference(io.prestosql.sql.tree.SymbolReference) Test(org.testng.annotations.Test)

Example 22 with TableScanNode

use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.

the class TestCostCalculator method testReplicatedJoinWithExchange.

@Test
public void testReplicatedJoinWithExchange() {
    TableScanNode ts1 = tableScan("ts1", "orderkey");
    TableScanNode ts2 = tableScan("ts2", "orderkey_0");
    ExchangeNode remoteExchange2 = replicatedExchange(new PlanNodeId("re2"), REMOTE, ts2);
    ExchangeNode localExchange = partitionedExchange(new PlanNodeId("le"), LOCAL, remoteExchange2, ImmutableList.of(new Symbol("orderkey_0")), Optional.empty());
    JoinNode join = join("join", ts1, localExchange, JoinNode.DistributionType.REPLICATED, "orderkey", "orderkey_0");
    Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.<String, PlanNodeStatsEstimate>builder().put("join", statsEstimate(join, 12000)).put("re2", statsEstimate(remoteExchange2, 10000)).put("le", statsEstimate(localExchange, 6000)).put("ts1", statsEstimate(ts1, 6000)).put("ts2", statsEstimate(ts2, 1000)).build();
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "orderkey_0", BIGINT);
    assertFragmentedEqualsUnfragmented(join, stats, types);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) TableScanNode(io.prestosql.spi.plan.TableScanNode) ExchangeNode(io.prestosql.sql.planner.plan.ExchangeNode) Symbol(io.prestosql.spi.plan.Symbol) JoinNode(io.prestosql.spi.plan.JoinNode) Test(org.testng.annotations.Test)

Example 23 with TableScanNode

use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.

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.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) TableScanNode(io.prestosql.spi.plan.TableScanNode) LimitNode(io.prestosql.spi.plan.LimitNode) Test(org.testng.annotations.Test)

Example 24 with TableScanNode

use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.

the class TestCostCalculator method tableScan.

private TableScanNode tableScan(String id, String... symbols) {
    List<Symbol> symbolsList = Arrays.stream(symbols).map(Symbol::new).collect(toImmutableList());
    ImmutableMap.Builder<Symbol, ColumnHandle> assignments = ImmutableMap.builder();
    for (Symbol symbol : symbolsList) {
        assignments.put(symbol, new TpchColumnHandle("orderkey", BIGINT));
    }
    TpchTableHandle tableHandle = new TpchTableHandle("orders", 1.0);
    return new TableScanNode(new PlanNodeId(id), new TableHandle(new CatalogName("tpch"), tableHandle, INSTANCE, Optional.of(new TpchTableLayoutHandle(tableHandle, TupleDomain.all()))), symbolsList, assignments.build(), TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
}
Also used : TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) ImmutableMap(com.google.common.collect.ImmutableMap) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TableScanNode(io.prestosql.spi.plan.TableScanNode) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) CatalogName(io.prestosql.spi.connector.CatalogName) UUID(java.util.UUID) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle)

Example 25 with TableScanNode

use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.

the class TestCostCalculator method testTableScan.

@Test
public void testTableScan() {
    TableScanNode tableScan = tableScan("ts", "orderkey");
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT);
    assertCost(tableScan, ImmutableMap.of(), ImmutableMap.of("ts", statsEstimate(tableScan, 1000)), types).cpu(1000 * IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostEstimatedExchanges(tableScan, ImmutableMap.of(), ImmutableMap.of("ts", statsEstimate(tableScan, 1000)), types).cpu(1000 * IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostFragmentedPlan(tableScan, ImmutableMap.of(), ImmutableMap.of("ts", statsEstimate(tableScan, 1000)), types).cpu(1000 * IS_NULL_OVERHEAD).memory(0).network(0);
    assertCostHasUnknownComponentsForUnknownStats(tableScan, types);
}
Also used : Type(io.prestosql.spi.type.Type) TableScanNode(io.prestosql.spi.plan.TableScanNode) Test(org.testng.annotations.Test)

Aggregations

TableScanNode (io.prestosql.spi.plan.TableScanNode)77 Symbol (io.prestosql.spi.plan.Symbol)42 PlanNode (io.prestosql.spi.plan.PlanNode)41 Test (org.testng.annotations.Test)33 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)30 FilterNode (io.prestosql.spi.plan.FilterNode)28 RowExpression (io.prestosql.spi.relation.RowExpression)24 Type (io.prestosql.spi.type.Type)22 JoinNode (io.prestosql.spi.plan.JoinNode)21 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)21 Map (java.util.Map)21 TableHandle (io.prestosql.spi.metadata.TableHandle)20 ProjectNode (io.prestosql.spi.plan.ProjectNode)20 Optional (java.util.Optional)20 ImmutableList (com.google.common.collect.ImmutableList)18 Expression (io.prestosql.sql.tree.Expression)18 HashMap (java.util.HashMap)16 List (java.util.List)16 ImmutableMap (com.google.common.collect.ImmutableMap)15 Session (io.prestosql.Session)15