use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testFilter.
@Test
public void testFilter() {
PlanNode node = filter(baseTableScan, and(greaterThan(AV, call(metadata.getFunctionAndTypeManager(), "rand", DOUBLE, ImmutableList.of())), lessThan(BV, bigintLiteral(10))));
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Non-deterministic functions should be purged
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(lessThan(BV, bigintLiteral(10))));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testSemiJoin.
@Test
public void testSemiJoin() {
PlanNode node = new SemiJoinNode(Optional.empty(), newId(), filter(baseTableScan, and(greaterThan(AV, bigintLiteral(10)), lessThan(AV, bigintLiteral(100)))), filter(baseTableScan, greaterThan(AV, bigintLiteral(5))), AV, BV, CV, Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Currently, only pull predicates through the source plan
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(and(greaterThan(AV, bigintLiteral(10)), lessThan(AV, bigintLiteral(100)))));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testUnion.
@Test
public void testUnion() {
PlanNode node = new UnionNode(Optional.empty(), newId(), ImmutableList.of(filter(baseTableScan, greaterThan(AV, bigintLiteral(10))), filter(baseTableScan, and(greaterThan(AV, bigintLiteral(10)), lessThan(AV, bigintLiteral(100)))), filter(baseTableScan, and(greaterThan(AV, bigintLiteral(10)), lessThan(AV, bigintLiteral(100))))), ImmutableList.of(AV), ImmutableMap.of(AV, ImmutableList.of(BV, CV, EV)));
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Only the common conjuncts can be inferred through a Union
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(greaterThan(AV, bigintLiteral(10))));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testTableScan.
@Test
public void testTableScan() {
// Effective predicate is True if there is no effective predicate
Map<VariableReferenceExpression, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(AV, BV, CV, DV)));
PlanNode node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), TupleDomain.all());
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, TRUE_CONSTANT);
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.none(), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, FALSE_CONSTANT);
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(AV), Domain.singleValue(BIGINT, 1L))), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(1L), AV)));
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(AV), Domain.singleValue(BIGINT, 1L), scanAssignments.get(BV), Domain.singleValue(BIGINT, 2L))), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(2L), BV), equals(bigintLiteral(1L), AV)));
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, TRUE_CONSTANT);
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testProject.
@Test
public void testProject() {
PlanNode node = new ProjectNode(newId(), filter(baseTableScan, and(equals(AV, BV), equals(BV, CV), lessThan(CV, bigintLiteral(10)))), assignment(DV, AV, EV, CV));
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Rewrite in terms of project output symbols
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(lessThan(DV, bigintLiteral(10)), equals(DV, EV)));
}
Aggregations