Skip to content

Commit

Permalink
Add PushPredicateIntoTableScan test where pushed domain is narrower
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Sep 30, 2019
1 parent 78771fa commit 32dcec6
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.airlift.slice.Slices;
import io.prestosql.connector.CatalogName;
import io.prestosql.metadata.TableHandle;
import io.prestosql.plugin.tpch.TpchColumnHandle;
Expand Down Expand Up @@ -144,6 +145,26 @@ public void consumesDeterministicPredicateIfNewDomainIsWider()
ImmutableMap.of("nationkey", "nationkey")));
}

@Test
public void consumesDeterministicPredicateIfNewDomainIsNarrower()
{
Type orderStatusType = createVarcharType(1);
ColumnHandle columnHandle = new TpchColumnHandle("orderstatus", orderStatusType);
Map<String, Domain> filterConstraint = ImmutableMap.<String, Domain>builder()
.put("orderstatus", singleValue(orderStatusType, utf8Slice("O")))
.build();
tester().assertThat(pushPredicateIntoTableScan)
.on(p -> p.filter(expression("orderstatus = 'O' OR orderstatus = 'F'"),
p.tableScan(
ordersTableHandle,
ImmutableList.of(p.symbol("orderstatus", orderStatusType)),
ImmutableMap.of(p.symbol("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType)),
TupleDomain.withColumnDomains(ImmutableMap.of(
columnHandle, Domain.multipleValues(orderStatusType, ImmutableList.of(Slices.utf8Slice("O"), Slices.utf8Slice("P"))))))))
.matches(
constrainedTableScanWithTableLayout("orders", filterConstraint, ImmutableMap.of("orderstatus", "orderstatus")));
}

@Test
public void doesNotConsumeRemainingPredicateIfNewDomainIsWider()
{
Expand Down

0 comments on commit 32dcec6

Please sign in to comment.