use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestCostCalculator method testMemoryCostJoinAboveJoin.
@Test
public void testMemoryCostJoinAboveJoin() {
// join
// / \
// ts1 join23
// / \
// ts2 ts3
TableScanNode ts1 = tableScan("ts1", "key1");
TableScanNode ts2 = tableScan("ts2", "key2");
TableScanNode ts3 = tableScan("ts3", "key3");
JoinNode join23 = join("join23", ts2, ts3, JoinNode.DistributionType.PARTITIONED, "key2", "key3");
JoinNode join = join("join", ts1, join23, JoinNode.DistributionType.PARTITIONED, "key1", "key2");
Map<String, PlanCostEstimate> costs = ImmutableMap.of("ts1", new PlanCostEstimate(0, 128, 128, 0), "ts2", new PlanCostEstimate(0, 64, 64, 0), "ts3", new PlanCostEstimate(0, 32, 32, 0));
Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.of("join", statsEstimate(join, 10_000), "join23", statsEstimate(join23, 2_000), "ts1", statsEstimate(ts1, 10_000), "ts2", statsEstimate(ts2, 1_000), "ts3", statsEstimate(ts3, 100));
Map<String, Type> types = ImmutableMap.of("key1", BIGINT, "key2", BIGINT, "key3", BIGINT);
assertCost(join23, costs, stats).memory(// join23 memory footprint
100 * IS_NULL_OVERHEAD + 64 + // ts2, ts3 memory footprint
32).memoryWhenOutputting(// join23 memory footprint
100 * IS_NULL_OVERHEAD + // ts2 memory footprint
64);
assertCost(join, costs, stats).memory(// join memory footprint
2000 * IS_NULL_OVERHEAD + 100 * IS_NULL_OVERHEAD + // join23 total memory when outputting
64 + // ts1 memory footprint
128).memoryWhenOutputting(// join memory footprint
2000 * IS_NULL_OVERHEAD + // ts1 memory footprint
128);
assertCostEstimatedExchanges(join23, costs, stats).memory(// join23 memory footprint
100 * IS_NULL_OVERHEAD + 64 + // ts2, ts3 memory footprint
32).memoryWhenOutputting(// join23 memory footprint
100 * IS_NULL_OVERHEAD + // ts2 memory footprint
64);
assertCostEstimatedExchanges(join, costs, stats).memory(// join memory footprint
2000 * IS_NULL_OVERHEAD + 100 * IS_NULL_OVERHEAD + // join23 total memory when outputting
64 + // ts1 memory footprint
128).memoryWhenOutputting(// join memory footprint
2000 * IS_NULL_OVERHEAD + // ts1 memory footprint
128);
assertCostSingleStageFragmentedPlan(join23, costs, stats, types).memory(// join23 memory footprint
100 * IS_NULL_OVERHEAD + 64 + // ts2, ts3 memory footprint
32).memoryWhenOutputting(// join23 memory footprint
100 * IS_NULL_OVERHEAD + // ts2 memory footprint
64);
assertCostSingleStageFragmentedPlan(join, costs, stats, types).memory(// join memory footprint
2000 * IS_NULL_OVERHEAD + 100 * IS_NULL_OVERHEAD + // join23 total memory when outputting
64 + // ts1 memory footprint
128).memoryWhenOutputting(// join memory footprint
2000 * IS_NULL_OVERHEAD + // ts1 memory footprint
128);
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
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).cpu(6000 + 1000 + (12000 + 6000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network(0);
assertCostEstimatedExchanges(join, costs, stats).cpu(6000 + 1000 + (12000 + 6000 + 1000 + 6000 + 1000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network((6000 + 1000) * IS_NULL_OVERHEAD);
assertCostSingleStageFragmentedPlan(join, costs, stats, types).cpu(6000 + 1000 + (12000 + 6000 + 1000) * IS_NULL_OVERHEAD).memory(1000 * IS_NULL_OVERHEAD).network(0);
assertCostHasUnknownComponentsForUnknownStats(join);
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestCostCalculator method testRepartitionedJoinWithExchange.
@Test
public void testRepartitionedJoinWithExchange() {
TableScanNode ts1 = tableScan("ts1", "orderkey");
TableScanNode ts2 = tableScan("ts2", "orderkey_0");
PlanNode p1 = project("p1", ts1, variable("orderkey_1", BIGINT), new SymbolReference("orderkey"));
ExchangeNode remoteExchange1 = systemPartitionedExchange(new PlanNodeId("re1"), REMOTE_STREAMING, p1, ImmutableList.of(new VariableReferenceExpression(Optional.empty(), "orderkey_1", BIGINT)), Optional.empty());
ExchangeNode remoteExchange2 = systemPartitionedExchange(new PlanNodeId("re2"), REMOTE_STREAMING, ts2, ImmutableList.of(new VariableReferenceExpression(Optional.empty(), "orderkey_0", BIGINT)), Optional.empty());
ExchangeNode localExchange = systemPartitionedExchange(new PlanNodeId("le"), LOCAL, remoteExchange2, ImmutableList.of(new VariableReferenceExpression(Optional.empty(), "orderkey_0", BIGINT)), Optional.empty());
JoinNode join = join("join", remoteExchange1, localExchange, JoinNode.DistributionType.PARTITIONED, "orderkey_1", "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("p1", statsEstimate(p1, 6000)).put("ts1", statsEstimate(ts1, 6000)).put("ts2", statsEstimate(ts2, 1000)).build();
Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT, "orderkey_1", BIGINT, "orderkey_0", BIGINT);
assertFragmentedEqualsUnfragmented(join, stats, types);
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
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 VariableReferenceExpression(Optional.empty(), symbols[i], BIGINT), new VariableReferenceExpression(Optional.empty(), symbols[i + 1], BIGINT)));
}
return new JoinNode(Optional.empty(), new PlanNodeId(planNodeId), JoinNode.Type.INNER, left, right, criteria.build(), ImmutableList.<VariableReferenceExpression>builder().addAll(left.getOutputVariables()).addAll(right.getOutputVariables()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(distributionType), ImmutableMap.of());
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestVerifyNoOriginalExpression method validateJoin.
private void validateJoin(RowExpression rowExpressionPredicate, Expression expressionPredicate, boolean ifRowExpression) {
ImmutableMap<VariableReferenceExpression, RowExpression> map = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, VARIABLE_REFERENCE_EXPRESSION);
ProjectNode projectNode = builder.project(new Assignments(map), valuesNode);
JoinNode joinNode;
if (ifRowExpression) {
joinNode = builder.join(JoinNode.Type.INNER, projectNode, projectNode, rowExpressionPredicate);
} else {
joinNode = builder.join(JoinNode.Type.INNER, projectNode, projectNode, castToRowExpression(expressionPredicate));
}
testValidation(joinNode);
}
Aggregations