use of io.trino.sql.planner.plan.JoinNode in project trino by trinodb.
the class TestEliminateCrossJoins method joinNode.
private JoinNode joinNode(PlanNode left, PlanNode right, String... symbols) {
checkArgument(symbols.length % 2 == 0);
ImmutableList.Builder<JoinNode.EquiJoinClause> criteria = ImmutableList.builder();
for (int i = 0; i < symbols.length; i += 2) {
criteria.add(new JoinNode.EquiJoinClause(new Symbol(symbols[i]), new Symbol(symbols[i + 1])));
}
return new JoinNode(idAllocator.getNextId(), JoinNode.Type.INNER, left, right, criteria.build(), left.getOutputSymbols(), right.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(), Optional.empty());
}
use of io.trino.sql.planner.plan.JoinNode 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);
}
use of io.trino.sql.planner.plan.JoinNode 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);
}
use of io.trino.sql.planner.plan.JoinNode in project trino by trinodb.
the class TestCostCalculator method join.
/**
* EquiJoinClause is created from symbols in form of:
* symbol[0] = symbol[1] AND symbol[2] = symbol[3] AND ...
*/
private JoinNode join(String planNodeId, PlanNode left, PlanNode right, JoinNode.DistributionType distributionType, String... symbols) {
checkArgument(symbols.length % 2 == 0);
ImmutableList.Builder<JoinNode.EquiJoinClause> criteria = ImmutableList.builder();
for (int i = 0; i < symbols.length; i += 2) {
criteria.add(new JoinNode.EquiJoinClause(new Symbol(symbols[i]), new Symbol(symbols[i + 1])));
}
return new JoinNode(new PlanNodeId(planNodeId), JoinNode.Type.INNER, left, right, criteria.build(), left.getOutputSymbols(), right.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(distributionType), Optional.empty(), ImmutableMap.of(), Optional.empty());
}
use of io.trino.sql.planner.plan.JoinNode 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);
}
Aggregations