use of io.trino.spi.predicate.TupleDomain in project trino by trinodb.
the class TableStatisticsMaker method dataFileMatches.
private boolean dataFileMatches(DataFile dataFile, Constraint constraint, List<PartitionField> partitionFields, Map<Integer, ColumnFieldDetails> fieldDetails) {
// Currently this method is used only for IcebergMetadata.getTableStatistics and there Constraint never carries a predicate.
// TODO support pruning with constraint when this changes.
verify(constraint.predicate().isEmpty(), "Unexpected Constraint predicate");
TupleDomain<ColumnHandle> constraintSummary = constraint.getSummary();
Map<ColumnHandle, Domain> domains = constraintSummary.getDomains().get();
for (int index = 0; index < partitionFields.size(); index++) {
PartitionField field = partitionFields.get(index);
int fieldId = field.fieldId();
ColumnFieldDetails details = fieldDetails.get(fieldId);
IcebergColumnHandle column = details.getColumnHandle();
Object value = convertIcebergValueToTrino(details.getIcebergType(), dataFile.partition().get(index, details.getJavaClass()));
Domain allowedDomain = domains.get(column);
if (allowedDomain != null && !allowedDomain.includesNullableValue(value)) {
return false;
}
}
return true;
}
use of io.trino.spi.predicate.TupleDomain in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testShortCircuitOnAllTupleDomain.
@Test
public void testShortCircuitOnAllTupleDomain() throws Exception {
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(new DynamicFilterId("123"), 0), ImmutableMap.of(new DynamicFilterId("123"), INTEGER), 2);
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("123"), Domain.all(INTEGER))));
assertEquals(result.get(), ImmutableMap.of(new DynamicFilterId("123"), Domain.all(INTEGER)));
// adding another partition domain won't change final domain
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 1L))));
assertEquals(result.get(), ImmutableMap.of(new DynamicFilterId("123"), Domain.all(INTEGER)));
}
use of io.trino.spi.predicate.TupleDomain in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testMultipleColumns.
@Test
public void testMultipleColumns() throws Exception {
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(new DynamicFilterId("123"), 0, new DynamicFilterId("456"), 1), ImmutableMap.of(new DynamicFilterId("123"), INTEGER, new DynamicFilterId("456"), INTEGER), 1);
assertEquals(filter.getBuildChannels(), ImmutableMap.of(new DynamicFilterId("123"), 0, new DynamicFilterId("456"), 1));
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 10L), new DynamicFilterId("456"), Domain.singleValue(INTEGER, 20L))));
assertEquals(result.get(), ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 10L), new DynamicFilterId("456"), Domain.singleValue(INTEGER, 20L)));
}
use of io.trino.spi.predicate.TupleDomain in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testSimple.
@Test
public void testSimple() throws Exception {
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(new DynamicFilterId("123"), 0), ImmutableMap.of(new DynamicFilterId("123"), INTEGER), 1);
assertEquals(filter.getBuildChannels(), ImmutableMap.of(new DynamicFilterId("123"), 0));
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 7L))));
assertEquals(result.get(), ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 7L)));
}
use of io.trino.spi.predicate.TupleDomain in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testAllDomain.
@Test
public void testAllDomain() throws Exception {
DynamicFilterId filter1 = new DynamicFilterId("123");
DynamicFilterId filter2 = new DynamicFilterId("124");
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(filter1, 0, filter2, 1), ImmutableMap.of(filter1, INTEGER, filter2, INTEGER), 1);
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(filter1, Domain.all(INTEGER), filter2, Domain.singleValue(INTEGER, 1L))));
assertEquals(result.get(), ImmutableMap.of(filter1, Domain.all(INTEGER), filter2, Domain.singleValue(INTEGER, 1L)));
}
Aggregations