Search in sources :

Example 21 with TableScanNode

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

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 : TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) Type(io.trino.spi.type.Type) TableScanNode(io.trino.sql.planner.plan.TableScanNode) Test(org.testng.annotations.Test)

Example 22 with TableScanNode

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

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"), toSqlType(VARCHAR)));
    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.trino.sql.tree.Cast) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) Type(io.trino.spi.type.Type) PlanNode(io.trino.sql.planner.plan.PlanNode) TableScanNode(io.trino.sql.planner.plan.TableScanNode) SymbolReference(io.trino.sql.tree.SymbolReference) Test(org.testng.annotations.Test)

Example 23 with TableScanNode

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

the class TestCostCalculator method testRepartitionedJoinWithExchange.

@Test
public void testRepartitionedJoinWithExchange() {
    TableScanNode ts1 = tableScan("ts1", "orderkey");
    TableScanNode ts2 = tableScan("ts2", "orderkey_0");
    ExchangeNode remoteExchange1 = partitionedExchange(new PlanNodeId("re1"), REMOTE, ts1, ImmutableList.of(new Symbol("orderkey")), Optional.empty());
    ExchangeNode remoteExchange2 = partitionedExchange(new PlanNodeId("re2"), REMOTE, ts2, ImmutableList.of(new Symbol("orderkey_0")), Optional.empty());
    ExchangeNode localExchange = partitionedExchange(new PlanNodeId("le"), LOCAL, remoteExchange2, ImmutableList.of(new Symbol("orderkey_0")), Optional.empty());
    JoinNode join = join("join", remoteExchange1, localExchange, JoinNode.DistributionType.PARTITIONED, "orderkey", "orderkey_0");
    Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.<String, PlanNodeStatsEstimate>builder().put("join", statsEstimate(join, 12000)).put("re1", statsEstimate(remoteExchange1, 10000)).put("re2", statsEstimate(remoteExchange2, 10000)).put("le", statsEstimate(localExchange, 6000)).put("ts1", statsEstimate(ts1, 6000)).put("ts2", statsEstimate(ts2, 1000)).buildOrThrow();
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "orderkey_0", BIGINT);
    assertFragmentedEqualsUnfragmented(join, stats, types);
}
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) ExchangeNode(io.trino.sql.planner.plan.ExchangeNode) Symbol(io.trino.sql.planner.Symbol) JoinNode(io.trino.sql.planner.plan.JoinNode) Test(org.testng.annotations.Test)

Example 24 with TableScanNode

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

the class TestCostCalculator method testRepartitionedJoin.

@Test
public void testRepartitionedJoin() {
    TableScanNode ts1 = tableScan("ts1", "orderkey");
    TableScanNode ts2 = tableScan("ts2", "orderkey_0");
    JoinNode join = join("join", ts1, ts2, JoinNode.DistributionType.PARTITIONED, "orderkey", "orderkey_0");
    Map<String, PlanCostEstimate> costs = ImmutableMap.of("ts1", cpuCost(6000), "ts2", cpuCost(1000));
    Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.of("join", statsEstimate(join, 12000), "ts1", statsEstimate(ts1, 6000), "ts2", statsEstimate(ts2, 1000));
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "orderkey_0", BIGINT);
    assertCost(join, costs, stats, types).cpu(6000 + 1000 + (12000 + 6000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network(0);
    assertCostEstimatedExchanges(join, costs, stats, types).cpu(6000 + 1000 + (12000 + 6000 + 1000 + 6000 + 1000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network((6000 + 1000) * IS_NULL_OVERHEAD);
    assertCostFragmentedPlan(join, costs, stats, types).cpu(6000 + 1000 + (12000 + 6000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network(0);
    assertCostHasUnknownComponentsForUnknownStats(join, types);
}
Also used : TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) Type(io.trino.spi.type.Type) TableScanNode(io.trino.sql.planner.plan.TableScanNode) JoinNode(io.trino.sql.planner.plan.JoinNode) Test(org.testng.annotations.Test)

Example 25 with TableScanNode

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

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)).buildOrThrow();
    Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "orderkey_0", BIGINT);
    assertFragmentedEqualsUnfragmented(join, stats, types);
}
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) ExchangeNode(io.trino.sql.planner.plan.ExchangeNode) Symbol(io.trino.sql.planner.Symbol) JoinNode(io.trino.sql.planner.plan.JoinNode) Test(org.testng.annotations.Test)

Aggregations

TableScanNode (io.trino.sql.planner.plan.TableScanNode)58 Test (org.testng.annotations.Test)34 Symbol (io.trino.sql.planner.Symbol)30 JoinNode (io.trino.sql.planner.plan.JoinNode)26 ColumnHandle (io.trino.spi.connector.ColumnHandle)24 PlanNode (io.trino.sql.planner.plan.PlanNode)21 Type (io.trino.spi.type.Type)18 FilterNode (io.trino.sql.planner.plan.FilterNode)17 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)17 Expression (io.trino.sql.tree.Expression)17 ImmutableList (com.google.common.collect.ImmutableList)14 TableHandle (io.trino.metadata.TableHandle)14 Session (io.trino.Session)13 TypeSignatureTranslator.toSqlType (io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType)13 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)13 ImmutableMap (com.google.common.collect.ImmutableMap)12 TestingColumnHandle (io.trino.testing.TestingMetadata.TestingColumnHandle)12 Optional (java.util.Optional)11 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)10 TupleDomain (io.trino.spi.predicate.TupleDomain)10