@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); }
@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); }
replicatedExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties());
replicatedExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties());
replicatedExchange(idAllocator.getNextId(), REMOTE, filteringSource.getNode()), filteringSource.getProperties());
replicatedExchange(idAllocator.getNextId(), REMOTE, filteringSource.getNode()), filteringSource.getProperties());
private PlanWithProperties planReplicatedJoin(JoinNode node, PlanWithProperties left) { // Broadcast Join PlanWithProperties right = node.getRight().accept(this, PreferredProperties.any()); if (left.getProperties().isSingleNode()) { if (!right.getProperties().isSingleNode() || (!isColocatedJoinEnabled(session) && hasMultipleSources(left.getNode(), right.getNode()))) { right = withDerivedProperties( gatheringExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties()); } } else { right = withDerivedProperties( replicatedExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties()); } return buildJoin(node, left, right, JoinNode.DistributionType.REPLICATED); }
private PlanWithProperties planReplicatedJoin(JoinNode node, PlanWithProperties left) { // Broadcast Join PlanWithProperties right = node.getRight().accept(this, PreferredProperties.any()); if (left.getProperties().isSingleNode()) { if (!right.getProperties().isSingleNode() || (!isColocatedJoinEnabled(session) && hasMultipleSources(left.getNode(), right.getNode()))) { right = withDerivedProperties( gatheringExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties()); } } else { right = withDerivedProperties( replicatedExchange(idAllocator.getNextId(), REMOTE, right.getNode()), right.getProperties()); } return buildJoin(node, left, right, JoinNode.DistributionType.REPLICATED); }