use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testRightJoin.
@Test
public void testRightJoin() throws Exception {
ImmutableList.Builder<JoinNode.EquiJoinClause> criteriaBuilder = ImmutableList.builder();
criteriaBuilder.add(new JoinNode.EquiJoinClause(A, D));
criteriaBuilder.add(new JoinNode.EquiJoinClause(B, E));
List<JoinNode.EquiJoinClause> criteria = criteriaBuilder.build();
Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
TableScanNode leftScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(leftAssignments.keySet()), leftAssignments, Optional.empty(), TupleDomain.all(), null);
Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
TableScanNode rightScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(rightAssignments.keySet()), rightAssignments, Optional.empty(), TupleDomain.all(), null);
FilterNode left = filter(leftScan, and(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), equals(GE, bigintLiteral(10))));
FilterNode right = filter(rightScan, and(equals(DE, EE), lessThan(FE, bigintLiteral(100))));
PlanNode node = new JoinNode(newId(), JoinNode.Type.RIGHT, left, right, criteria, ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// All left side symbols should be checked against NULL
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(or(lessThan(BE, AE), and(isNull(BE), isNull(AE))), or(lessThan(CE, bigintLiteral(10)), isNull(CE)), equals(DE, EE), lessThan(FE, bigintLiteral(100)), or(equals(AE, DE), isNull(AE)), or(equals(BE, EE), isNull(BE))));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testRightJoinWithFalseInner.
@Test
public void testRightJoinWithFalseInner() throws Exception {
List<JoinNode.EquiJoinClause> criteria = ImmutableList.of(new JoinNode.EquiJoinClause(A, D));
Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
TableScanNode leftScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(leftAssignments.keySet()), leftAssignments, Optional.empty(), TupleDomain.all(), null);
Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
TableScanNode rightScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(rightAssignments.keySet()), rightAssignments, Optional.empty(), TupleDomain.all(), null);
FilterNode left = filter(leftScan, FALSE_LITERAL);
FilterNode right = filter(rightScan, and(equals(DE, EE), lessThan(FE, bigintLiteral(100))));
PlanNode node = new JoinNode(newId(), JoinNode.Type.RIGHT, left, right, criteria, ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// False literal on the left side should be ignored
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(DE, EE), lessThan(FE, bigintLiteral(100)), or(equals(AE, DE), isNull(AE))));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testLeftJoinWithFalseInner.
@Test
public void testLeftJoinWithFalseInner() throws Exception {
List<JoinNode.EquiJoinClause> criteria = ImmutableList.of(new JoinNode.EquiJoinClause(A, D));
Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
TableScanNode leftScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(leftAssignments.keySet()), leftAssignments, Optional.empty(), TupleDomain.all(), null);
Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
TableScanNode rightScan = new TableScanNode(newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(rightAssignments.keySet()), rightAssignments, Optional.empty(), TupleDomain.all(), null);
FilterNode left = filter(leftScan, and(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), equals(GE, bigintLiteral(10))));
FilterNode right = filter(rightScan, FALSE_LITERAL);
PlanNode node = new JoinNode(newId(), JoinNode.Type.LEFT, left, right, criteria, ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// False literal on the right side should be ignored
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), or(equals(AE, DE), isNull(DE))));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testGroupByEmpty.
@Test
public void testGroupByEmpty() throws Exception {
PlanNode node = new AggregationNode(newId(), filter(baseTableScan, FALSE_LITERAL), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of(ImmutableList.of()), AggregationNode.Step.FINAL, Optional.empty(), Optional.empty());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
assertEquals(effectivePredicate, TRUE_LITERAL);
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testLimit.
@Test
public void testLimit() throws Exception {
PlanNode node = new LimitNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), 1, false);
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
Aggregations