use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestLocalDynamicFilter method testCreateSingleColumn.
@Test
public void testCreateSingleColumn() throws ExecutionException, InterruptedException {
SubPlan subplan = subplan("SELECT count() FROM lineitem, orders WHERE lineitem.orderkey = orders.orderkey " + "AND orders.custkey < 10", LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED, false);
JoinNode joinNode = searchJoins(subplan.getChildren().get(0).getFragment()).findOnlyElement();
LocalDynamicFilter filter = LocalDynamicFilter.create(joinNode, 1).orElseThrow(NoSuchElementException::new);
String filterId = Iterables.getOnlyElement(filter.getBuildChannels().keySet());
VariableReferenceExpression probeVariable = Iterables.getOnlyElement(joinNode.getCriteria()).getLeft();
filter.getTupleDomainConsumer().accept(TupleDomain.withColumnDomains(ImmutableMap.of(filterId, Domain.singleValue(BIGINT, 3L))));
assertEquals(filter.getResultFuture().get(), TupleDomain.withColumnDomains(ImmutableMap.of(probeVariable, Domain.singleValue(BIGINT, 3L))));
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestLocalDynamicFilter method testCreateDistributedJoin.
@Test
public void testCreateDistributedJoin() {
Session session = Session.builder(getQueryRunner().getDefaultSession()).setSystemProperty(JOIN_DISTRIBUTION_TYPE, "PARTITIONED").build();
SubPlan subplan = subplan("SELECT count() FROM nation, region WHERE nation.regionkey = region.regionkey " + "AND region.comment = 'abc'", LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED, false, session);
JoinNode joinNode = searchJoins(subplan.getChildren().get(0).getFragment()).findOnlyElement();
assertFalse(joinNode.getDynamicFilters().isEmpty());
assertEquals(LocalDynamicFilter.create(joinNode, 1), Optional.empty());
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestEliminateCrossJoins method joinNode.
private JoinNode joinNode(PlanNode left, PlanNode right, VariableReferenceExpression... variables) {
checkArgument(variables.length % 2 == 0);
ImmutableList.Builder<JoinNode.EquiJoinClause> criteria = ImmutableList.builder();
for (int i = 0; i < variables.length; i += 2) {
criteria.add(new JoinNode.EquiJoinClause(variables[i], variables[i + 1]));
}
return new JoinNode(Optional.empty(), idAllocator.getNextId(), JoinNode.Type.INNER, left, right, criteria.build(), ImmutableList.<VariableReferenceExpression>builder().addAll(left.getOutputVariables()).addAll(right.getOutputVariables()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class DynamicFilterMatcher method match.
private boolean match() {
checkState(symbolAliases != null, "symbolAliases is null");
// both nodes must be provided to do the matching
if (filterNode == null || joinNode == null) {
return true;
}
Map<String, VariableReferenceExpression> idToProbeSymbolMap = extractDynamicFilters(filterNode.getPredicate()).getDynamicConjuncts().stream().collect(toImmutableMap(DynamicFilters.DynamicFilterPlaceholder::getId, filter -> (VariableReferenceExpression) filter.getInput()));
Map<String, VariableReferenceExpression> idToBuildSymbolMap = joinNode.getDynamicFilters();
if (idToProbeSymbolMap == null) {
return false;
}
if (idToProbeSymbolMap.size() != expectedDynamicFilters.size()) {
return false;
}
Map<Symbol, Symbol> actual = new HashMap<>();
for (Map.Entry<String, VariableReferenceExpression> idToProbeSymbol : idToProbeSymbolMap.entrySet()) {
String id = idToProbeSymbol.getKey();
VariableReferenceExpression probe = idToProbeSymbol.getValue();
VariableReferenceExpression build = idToBuildSymbolMap.get(id);
if (build == null) {
return false;
}
actual.put(new Symbol(probe.getName()), new Symbol(build.getName()));
}
Map<Symbol, Symbol> expected = expectedDynamicFilters.entrySet().stream().collect(toImmutableMap(entry -> entry.getKey().toSymbol(symbolAliases), entry -> entry.getValue().toSymbol(symbolAliases)));
return expected.equals(actual);
}
use of com.facebook.presto.sql.planner.plan.JoinNode in project presto by prestodb.
the class TestJoinNodeFlattener method testDoesNotAllowOuterJoin.
@Test(expectedExceptions = IllegalStateException.class)
public void testDoesNotAllowOuterJoin() {
PlanBuilder p = planBuilder();
VariableReferenceExpression a1 = p.variable("A1");
VariableReferenceExpression b1 = p.variable("B1");
JoinNode outerJoin = p.join(FULL, p.values(a1), p.values(b1), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
toMultiJoinNode(outerJoin, noLookup(), DEFAULT_JOIN_LIMIT, functionResolution, determinismEvaluator);
}
Aggregations