use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.
the class TestLocalDynamicFiltersCollector method testComparison.
@Test
public void testComparison() {
LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
DynamicFilterId filterId1 = new DynamicFilterId("filter1");
DynamicFilterId filterId2 = new DynamicFilterId("filter2");
collector.register(ImmutableSet.of(filterId1, filterId2));
SymbolAllocator symbolAllocator = new SymbolAllocator();
Symbol symbol = symbolAllocator.newSymbol("symbol", BIGINT);
ColumnHandle column = new TestingColumnHandle("column");
DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filterId1, symbol.toSymbolReference(), GREATER_THAN), new DynamicFilters.Descriptor(filterId2, symbol.toSymbolReference(), LESS_THAN)), 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());
assertFalse(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.all());
collector.collectDynamicFilterDomains(ImmutableMap.of(filterId1, Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L)), filterId2, Domain.multipleValues(BIGINT, ImmutableList.of(4L, 5L, 6L))));
// Unblocked and completed.
assertTrue(filter.isComplete());
assertTrue(isBlocked.isDone());
assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(column, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, false, 6L, false)), false))));
}
use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.
the class TestSchedulingOrderVisitor method testSemiJoinOrder.
@Test
public void testSemiJoinOrder() {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), TEST_SESSION);
Symbol sourceJoin = planBuilder.symbol("sourceJoin");
TableScanNode a = planBuilder.tableScan(ImmutableList.of(sourceJoin), ImmutableMap.of(sourceJoin, new TestingColumnHandle("sourceJoin")));
Symbol filteringSource = planBuilder.symbol("filteringSource");
TableScanNode b = planBuilder.tableScan(ImmutableList.of(filteringSource), ImmutableMap.of(filteringSource, new TestingColumnHandle("filteringSource")));
List<PlanNodeId> order = scheduleOrder(planBuilder.semiJoin(sourceJoin, filteringSource, planBuilder.symbol("semiJoinOutput"), Optional.empty(), Optional.empty(), a, b));
assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
Aggregations