{
// Effective predicate is True if there are no generated partitions
Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D)));
PlanNode node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>absent());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(effectivePredicate, BooleanLiteral.TRUE_LITERAL);
// tupleDomainInput with no matching partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(scanAssignments.get(A), Domain.singleValue(1L))),
ImmutableList.<Partition>of())));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(effectivePredicate, BooleanLiteral.FALSE_LITERAL);
// tupleDomainInput with non-descriptive partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(scanAssignments.get(A), Domain.singleValue(1L))),
ImmutableList.<Partition>of(new DualPartition()))));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(number(1L), AE)));
// tupleDomainInput with descriptive partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(scanAssignments.get(A), Domain.singleValue(1L))),
ImmutableList.<Partition>of(tupleDomainPartition(TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(
scanAssignments.get(A), Domain.singleValue(1L),
scanAssignments.get(B), Domain.singleValue(2L))))))));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(number(2L), BE), equals(number(1L), AE)));
// generic tupleDomainInput with no matching partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.all(),
ImmutableList.<Partition>of())));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(effectivePredicate, BooleanLiteral.FALSE_LITERAL);
// generic tupleDomainInput with non-descriptive partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.all(),
ImmutableList.<Partition>of(new DualPartition()))));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(effectivePredicate, BooleanLiteral.TRUE_LITERAL);
// generic tupleDomainInput with descriptive partitions
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.copyOf(assignments.keySet()),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.all(),
ImmutableList.<Partition>of(tupleDomainPartition(TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(
scanAssignments.get(A), Domain.singleValue(1L),
scanAssignments.get(B), Domain.singleValue(2L))))))));
effectivePredicate = EffectivePredicateExtractor.extract(node);
Assert.assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(number(2L), BE), equals(number(1L), AE)));
// Make sure only output symbols are produced
node = new TableScanNode(
newId(),
new DualTableHandle("default"),
ImmutableList.of(A),
assignments,
null,
Optional.<GeneratedPartitions>of(new GeneratedPartitions(
TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(