Search in sources :

Example 21 with TestingColumnHandle

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))));
}
Also used : TestingColumnHandle(io.trino.spi.connector.TestingColumnHandle) ColumnHandle(io.trino.spi.connector.ColumnHandle) TestingColumnHandle(io.trino.spi.connector.TestingColumnHandle) DynamicFilter(io.trino.spi.connector.DynamicFilter) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 22 with TestingColumnHandle

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()));
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TestingColumnHandle(io.trino.spi.connector.TestingColumnHandle) TableScanNode(io.trino.sql.planner.plan.TableScanNode) PlanBuilder(io.trino.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Aggregations

TestingColumnHandle (io.trino.spi.connector.TestingColumnHandle)22 Test (org.testng.annotations.Test)22 DynamicFilter (io.trino.spi.connector.DynamicFilter)19 DynamicFilterId (io.trino.sql.planner.plan.DynamicFilterId)19 ColumnHandle (io.trino.spi.connector.ColumnHandle)14 Symbol (io.trino.sql.planner.Symbol)11 QueryId (io.trino.spi.QueryId)10 SymbolAllocator (io.trino.sql.planner.SymbolAllocator)10 StageId (io.trino.execution.StageId)9 TaskId (io.trino.execution.TaskId)8 DynamicFilters.createDynamicFilterExpression (io.trino.sql.DynamicFilters.createDynamicFilterExpression)7 Expression (io.trino.sql.tree.Expression)7 Domain (io.trino.spi.predicate.Domain)6 TupleDomain (io.trino.spi.predicate.TupleDomain)6 Duration (io.airlift.units.Duration)2 RemoteTask (io.trino.execution.RemoteTask)2 DynamicFilterService (io.trino.server.DynamicFilterService)2 DynamicFilterDomainStats (io.trino.server.DynamicFilterService.DynamicFilterDomainStats)2 DynamicFiltersStats (io.trino.server.DynamicFilterService.DynamicFiltersStats)2 HttpRemoteTaskFactory (io.trino.server.HttpRemoteTaskFactory)2