use of io.trino.spi.predicate.Domain in project trino by trinodb.
the class PartitionFilterBuilder method addStringValues.
public PartitionFilterBuilder addStringValues(String columnName, String... values) {
List<Slice> blockValues = Arrays.stream(values).map(Slices::utf8Slice).collect(toImmutableList());
Domain domain = Domain.multipleValues(VarcharType.VARCHAR, blockValues);
domains.merge(columnName, domain, Domain::union);
return this;
}
use of io.trino.spi.predicate.Domain in project trino by trinodb.
the class PartitionFilterBuilder method addSmallintValues.
public PartitionFilterBuilder addSmallintValues(String columnName, Long... values) {
Domain domain = Domain.multipleValues(SmallintType.SMALLINT, Arrays.asList(values));
domains.merge(columnName, domain, Domain::union);
return this;
}
use of io.trino.spi.predicate.Domain in project trino by trinodb.
the class PartitionFilterBuilder method addDecimalValues.
public PartitionFilterBuilder addDecimalValues(String columnName, String... values) {
checkArgument(values.length > 0);
List<Long> encodedValues = Arrays.stream(values).map(PartitionFilterBuilder::decimalOf).collect(toImmutableList());
Domain domain = Domain.multipleValues(DECIMAL_TYPE, encodedValues);
domains.merge(columnName, domain, Domain::union);
return this;
}
use of io.trino.spi.predicate.Domain in project trino by trinodb.
the class TestGlueExpressionUtil method testBuildGlueExpressionDomainEqualsSingleValue.
@Test
public void testBuildGlueExpressionDomainEqualsSingleValue() {
Domain domain = Domain.singleValue(VarcharType.VARCHAR, utf8Slice("2020-01-01"));
Optional<String> foo = buildGlueExpressionForSingleDomain("foo", domain, true);
assertEquals(foo.get(), "((foo = '2020-01-01'))");
}
use of io.trino.spi.predicate.Domain in project trino by trinodb.
the class BaseIcebergConnectorTest method assertFilterPushdown.
private void assertFilterPushdown(QualifiedObjectName tableName, Map<String, Domain> filter, Map<String, Domain> expectedEnforcedPredicate, Map<String, Domain> expectedUnenforcedPredicate) {
Metadata metadata = getQueryRunner().getMetadata();
newTransaction().execute(getSession(), session -> {
TableHandle table = metadata.getTableHandle(session, tableName).orElseThrow(() -> new TableNotFoundException(tableName.asSchemaTableName()));
Map<String, ColumnHandle> columns = metadata.getColumnHandles(session, table);
TupleDomain<ColumnHandle> domains = TupleDomain.withColumnDomains(filter.entrySet().stream().collect(toImmutableMap(entry -> columns.get(entry.getKey()), Map.Entry::getValue)));
Optional<ConstraintApplicationResult<TableHandle>> result = metadata.applyFilter(session, table, new Constraint(domains));
assertTrue(result.isEmpty() == (expectedUnenforcedPredicate == null && expectedEnforcedPredicate == null));
if (result.isPresent()) {
IcebergTableHandle newTable = (IcebergTableHandle) result.get().getHandle().getConnectorHandle();
assertEquals(newTable.getEnforcedPredicate(), TupleDomain.withColumnDomains(expectedEnforcedPredicate.entrySet().stream().collect(toImmutableMap(entry -> columns.get(entry.getKey()), Map.Entry::getValue))));
assertEquals(newTable.getUnenforcedPredicate(), TupleDomain.withColumnDomains(expectedUnenforcedPredicate.entrySet().stream().collect(toImmutableMap(entry -> columns.get(entry.getKey()), Map.Entry::getValue))));
}
});
}
Aggregations