use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFilterSourceOperator method testCollectWithNulls.
@Test
public void testCollectWithNulls() {
Block blockWithNulls = INTEGER.createFixedSizeBlockBuilder(0).writeInt(3).appendNull().writeInt(4).build();
OperatorFactory operatorFactory = createOperatorFactory(channel(0, INTEGER));
verifyPassthrough(createOperator(operatorFactory), ImmutableList.of(INTEGER), new Page(createLongsBlock(1, 2, 3)), new Page(blockWithNulls), new Page(createLongsBlock(4, 5)));
operatorFactory.noMoreOperators();
assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.create(ValueSet.of(INTEGER, 1L, 2L, 3L, 4L, 5L), false)))));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFilterSourceOperator method testMultipleColumnsCollectBelowDistinctValuesLimit.
@Test
public void testMultipleColumnsCollectBelowDistinctValuesLimit() {
int maxDistinctValues = 101;
Page largePage = new Page(createLongSequenceBlock(0, 101), createLongSequenceBlock(100, 201), createLongSequenceBlock(200, 301));
List<TupleDomain<DynamicFilterId>> expectedTupleDomains = ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.create(ValueSet.copyOf(BIGINT, LongStream.rangeClosed(0L, 100L).boxed().collect(toImmutableList())), false), new DynamicFilterId("1"), Domain.create(ValueSet.copyOf(BIGINT, LongStream.rangeClosed(100L, 200L).boxed().collect(toImmutableList())), false), new DynamicFilterId("2"), Domain.create(ValueSet.copyOf(BIGINT, LongStream.rangeClosed(200L, 300L).boxed().collect(toImmutableList())), false))));
assertDynamicFilters(maxDistinctValues, ImmutableList.of(BIGINT, BIGINT, BIGINT), ImmutableList.of(largePage), expectedTupleDomains);
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestLocalDynamicFiltersCollector method testDynamicFilterCoercion.
@Test
public void testDynamicFilterCoercion() {
LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
DynamicFilterId filterId = new DynamicFilterId("filter");
collector.register(ImmutableSet.of(filterId));
SymbolAllocator symbolAllocator = new SymbolAllocator();
Symbol symbol = symbolAllocator.newSymbol("symbol", INTEGER);
ColumnHandle column = new TestingColumnHandle("column");
DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filterId, new Cast(symbol.toSymbolReference(), toSqlType(BIGINT)))), ImmutableMap.of(symbol, column), symbolAllocator.getTypes());
assertEquals(filter.getColumnsCovered(), Set.of(column), "columns covered");
// Filter is blocked and not completed.
CompletableFuture<?> isBlocked = filter.isBlocked();
assertFalse(filter.isComplete());
assertTrue(filter.isAwaitable());
assertFalse(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.all());
Domain domain = Domain.singleValue(BIGINT, 7L);
collector.collectDynamicFilterDomains(ImmutableMap.of(filterId, domain));
// Unblocked and completed.
assertTrue(filter.isComplete());
assertFalse(filter.isAwaitable());
assertTrue(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(column, Domain.singleValue(INTEGER, 7L))));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestLocalDynamicFiltersCollector method testMultipleBuildColumnsSingleProbeColumn.
@Test
public void testMultipleBuildColumnsSingleProbeColumn() {
LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
DynamicFilterId filter1 = new DynamicFilterId("filter1");
DynamicFilterId filter2 = new DynamicFilterId("filter2");
collector.register(ImmutableSet.of(filter1));
collector.register(ImmutableSet.of(filter2));
// Multiple build-side columns matching the same probe-side column.
SymbolAllocator symbolAllocator = new SymbolAllocator();
Symbol symbol = symbolAllocator.newSymbol("symbol", BIGINT);
ColumnHandle column = new TestingColumnHandle("column");
DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filter1, symbol.toSymbolReference()), new DynamicFilters.Descriptor(filter2, symbol.toSymbolReference())), ImmutableMap.of(symbol, column), symbolAllocator.getTypes());
assertEquals(filter.getColumnsCovered(), Set.of(column), "columns covered");
// Filter is blocking and not completed.
CompletableFuture<?> isBlocked = filter.isBlocked();
assertFalse(filter.isComplete());
assertTrue(filter.isAwaitable());
assertFalse(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.all());
collector.collectDynamicFilterDomains(ImmutableMap.of(filter1, Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L))));
// Unblocked, but not completed.
assertFalse(filter.isComplete());
assertTrue(filter.isAwaitable());
assertTrue(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(column, Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L)))));
// Create a new blocking future, waiting for next completion.
isBlocked = filter.isBlocked();
assertFalse(isBlocked.isDone());
assertFalse(filter.isComplete());
assertTrue(filter.isAwaitable());
collector.collectDynamicFilterDomains(ImmutableMap.of(filter2, Domain.multipleValues(BIGINT, ImmutableList.of(2L, 3L, 4L))));
// Unblocked and completed.
assertTrue(filter.isComplete());
assertFalse(filter.isAwaitable());
assertTrue(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(column, Domain.multipleValues(BIGINT, ImmutableList.of(2L, 3L)))));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testDynamicFilterPruning.
@Test
public void testDynamicFilterPruning() throws Exception {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), getQueryRunner().getDefaultSession());
Symbol left1 = planBuilder.symbol("left1", BIGINT);
Symbol left2 = planBuilder.symbol("left2", INTEGER);
Symbol left3 = planBuilder.symbol("left3", SMALLINT);
Symbol right1 = planBuilder.symbol("right1", BIGINT);
Symbol right2 = planBuilder.symbol("right2", INTEGER);
Symbol right3 = planBuilder.symbol("right3", SMALLINT);
DynamicFilterId filter1 = new DynamicFilterId("filter1");
DynamicFilterId filter2 = new DynamicFilterId("filter2");
DynamicFilterId filter3 = new DynamicFilterId("filter3");
JoinNode joinNode = planBuilder.join(INNER, planBuilder.values(left1, left2, left3), planBuilder.values(right1, right2, right3), ImmutableList.of(new EquiJoinClause(left1, right1), new EquiJoinClause(left2, right2), new EquiJoinClause(left3, right3)), ImmutableList.of(), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(filter1, right1, filter2, right2, filter3, right3));
LocalDynamicFilterConsumer consumer = LocalDynamicFilterConsumer.create(joinNode, ImmutableList.of(BIGINT, INTEGER, SMALLINT), 1, ImmutableSet.of(filter1, filter3));
assertEquals(consumer.getBuildChannels(), ImmutableMap.of(filter1, 0, filter3, 2));
// make sure domain types got propagated correctly
consumer.getTupleDomainConsumer().accept(TupleDomain.none());
assertEquals(consumer.getDynamicFilterDomains().get(), ImmutableMap.of(filter1, Domain.none(BIGINT), filter3, Domain.none(SMALLINT)));
}
Aggregations