use of io.trino.spi.connector.Constraint in project trino by trinodb.
the class TestTpchMetadata method testOrdersOrderStatusPredicatePushdown.
@Test
public void testOrdersOrderStatusPredicatePushdown() {
TpchTableHandle tableHandle = tpchMetadata.getTableHandle(session, new SchemaTableName("sf1", ORDERS.getTableName()));
TupleDomain<ColumnHandle> domain;
ConstraintApplicationResult<ConnectorTableHandle> result;
domain = fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("P"));
result = tpchMetadata.applyFilter(session, tableHandle, new Constraint(domain, convertToPredicate(domain, ORDER_STATUS), Set.of(tpchMetadata.toColumnHandle(ORDER_STATUS)))).get();
assertTupleDomainEquals(result.getRemainingFilter(), TupleDomain.all(), session);
assertTupleDomainEquals(((TpchTableHandle) result.getHandle()).getConstraint(), domain, session);
domain = fixedValueTupleDomain(tpchMetadata, ORDER_KEY, 42L);
result = tpchMetadata.applyFilter(session, tableHandle, new Constraint(domain, convertToPredicate(domain, ORDER_STATUS), Set.of(tpchMetadata.toColumnHandle(ORDER_STATUS)))).get();
assertTupleDomainEquals(result.getRemainingFilter(), domain, session);
assertTupleDomainEquals(((TpchTableHandle) result.getHandle()).getConstraint(), // Using concrete expected value instead of checking TupleDomain::isNone to make sure the test doesn't pass on some other wrong value.
TupleDomain.columnWiseUnion(fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("F")), fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("O")), fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("P"))), session);
}
Aggregations