Search in sources :

Example 16 with TestingColumnHandle

use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.

the class TestLocalDynamicFiltersCollector method testMultipleProbeColumns.

@Test
public void testMultipleProbeColumns() {
    LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
    DynamicFilterId filterId = new DynamicFilterId("filter");
    collector.register(ImmutableSet.of(filterId));
    // Same build-side column being matched to multiple probe-side columns.
    SymbolAllocator symbolAllocator = new SymbolAllocator();
    Symbol symbol1 = symbolAllocator.newSymbol("symbol1", BIGINT);
    Symbol symbol2 = symbolAllocator.newSymbol("symbol2", BIGINT);
    ColumnHandle column1 = new TestingColumnHandle("column1");
    ColumnHandle column2 = new TestingColumnHandle("column2");
    DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filterId, symbol1.toSymbolReference()), new DynamicFilters.Descriptor(filterId, symbol2.toSymbolReference())), ImmutableMap.of(symbol1, column1, symbol2, column2), symbolAllocator.getTypes());
    assertEquals(filter.getColumnsCovered(), Set.of(column1, column2), "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(column1, domain, column2, domain)));
}
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) Domain(io.trino.spi.predicate.Domain) TupleDomain(io.trino.spi.predicate.TupleDomain) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 17 with TestingColumnHandle

use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.

the class TestLocalDynamicFiltersCollector method testUnusedDynamicFilter.

@Test
public void testUnusedDynamicFilter() {
    LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
    DynamicFilterId unusedFilterId = new DynamicFilterId("unused");
    DynamicFilterId usedFilterId = new DynamicFilterId("used");
    collector.register(ImmutableSet.of(unusedFilterId));
    collector.register(ImmutableSet.of(usedFilterId));
    // One of the dynamic filters is not used for the the table scan.
    SymbolAllocator symbolAllocator = new SymbolAllocator();
    Symbol usedSymbol = symbolAllocator.newSymbol("used", BIGINT);
    ColumnHandle usedColumn = new TestingColumnHandle("used");
    DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(usedFilterId, usedSymbol.toSymbolReference())), ImmutableMap.of(usedSymbol, usedColumn), symbolAllocator.getTypes());
    // 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(unusedFilterId, Domain.singleValue(BIGINT, 1L)));
    // This dynamic filter is unused here - has no effect on blocking/completion of the above future.
    assertFalse(filter.isComplete());
    assertFalse(isBlocked.isDone());
    assertEquals(filter.getCurrentPredicate(), TupleDomain.all());
    collector.collectDynamicFilterDomains(ImmutableMap.of(usedFilterId, Domain.singleValue(BIGINT, 2L)));
    // Unblocked and completed.
    assertTrue(filter.isComplete());
    assertFalse(filter.isAwaitable());
    assertTrue(isBlocked.isDone());
    assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(usedColumn, Domain.singleValue(BIGINT, 2L))));
}
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 18 with TestingColumnHandle

use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.

the class TestLocalDynamicFiltersCollector method testIsNotDistinctFrom.

@Test
public void testIsNotDistinctFrom() {
    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 symbol1 = symbolAllocator.newSymbol("symbol1", BIGINT);
    Symbol symbol2 = symbolAllocator.newSymbol("symbol2", BIGINT);
    ColumnHandle column1 = new TestingColumnHandle("column1");
    ColumnHandle column2 = new TestingColumnHandle("column2");
    DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filterId1, symbol1.toSymbolReference(), EQUAL, true), new DynamicFilters.Descriptor(filterId2, symbol2.toSymbolReference(), EQUAL, true)), ImmutableMap.of(symbol1, column1, symbol2, column2), symbolAllocator.getTypes());
    assertEquals(filter.getColumnsCovered(), Set.of(column1, column2), "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(4L, 5L, 6L)), filterId2, Domain.none(BIGINT)));
    // Unblocked and completed.
    assertTrue(filter.isComplete());
    assertTrue(isBlocked.isDone());
    assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(column1, Domain.create(ValueSet.of(BIGINT, 4L, 5L, 6L), true), column2, Domain.onlyNull(BIGINT))));
}
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 19 with TestingColumnHandle

use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.

the class TestLocalDynamicFiltersCollector method testUnregisteredDynamicFilter.

@Test
public void testUnregisteredDynamicFilter() {
    // One dynamic filter is not collected locally (e.g. due to a distributed join)
    LocalDynamicFiltersCollector collector = new LocalDynamicFiltersCollector(TEST_SESSION);
    DynamicFilterId registeredFilterId = new DynamicFilterId("registered");
    DynamicFilterId unregisteredFilterId = new DynamicFilterId("unregistered");
    collector.register(ImmutableSet.of(registeredFilterId));
    SymbolAllocator symbolAllocator = new SymbolAllocator();
    Symbol registeredSymbol = symbolAllocator.newSymbol("registered", BIGINT);
    Symbol unregisteredSymbol = symbolAllocator.newSymbol("unregistered", BIGINT);
    ColumnHandle registeredColumn = new TestingColumnHandle("registered");
    ColumnHandle unregisteredColumn = new TestingColumnHandle("unregistered");
    DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(registeredFilterId, registeredSymbol.toSymbolReference()), new DynamicFilters.Descriptor(unregisteredFilterId, unregisteredSymbol.toSymbolReference())), ImmutableMap.of(registeredSymbol, registeredColumn, unregisteredSymbol, unregisteredColumn), symbolAllocator.getTypes());
    // Filter is blocked 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(registeredFilterId, Domain.singleValue(BIGINT, 2L)));
    // Unblocked and completed (don't wait for filter2)
    assertTrue(filter.isComplete());
    assertFalse(filter.isAwaitable());
    assertTrue(isBlocked.isDone());
    assertEquals(filter.getCurrentPredicate(), TupleDomain.withColumnDomains(ImmutableMap.of(registeredColumn, Domain.singleValue(BIGINT, 2L))));
}
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 20 with TestingColumnHandle

use of io.trino.spi.connector.TestingColumnHandle in project trino by trinodb.

the class TestLocalDynamicFiltersCollector method testSingleEquality.

@Test
public void testSingleEquality() {
    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", BIGINT);
    ColumnHandle column = new TestingColumnHandle("column");
    DynamicFilter filter = createDynamicFilter(collector, ImmutableList.of(new DynamicFilters.Descriptor(filterId, symbol.toSymbolReference())), 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)));
}
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) Domain(io.trino.spi.predicate.Domain) TupleDomain(io.trino.spi.predicate.TupleDomain) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) 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