Search in sources :

Example 76 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFilterSourceOperator method testCollectOnlyLastColumn.

@Test
public void testCollectOnlyLastColumn() {
    OperatorFactory operatorFactory = createOperatorFactory(channel(1, DOUBLE));
    verifyPassthrough(createOperator(operatorFactory), ImmutableList.of(BOOLEAN, DOUBLE), new Page(createBooleansBlock(true, 2), createDoublesBlock(1.5, 3.0)), new Page(createBooleansBlock(false, 1), createDoublesBlock(4.5)));
    operatorFactory.noMoreOperators();
    assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("1"), Domain.multipleValues(DOUBLE, ImmutableList.of(1.5, 3.0, 4.5))))));
}
Also used : Page(io.trino.spi.Page) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 77 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFilterSourceOperator method testCollectWithDoubleNaN.

@Test
public void testCollectWithDoubleNaN() {
    BlockBuilder input = DOUBLE.createBlockBuilder(null, 10);
    DOUBLE.writeDouble(input, 42.0);
    DOUBLE.writeDouble(input, Double.NaN);
    OperatorFactory operatorFactory = createOperatorFactory(channel(0, DOUBLE));
    verifyPassthrough(createOperator(operatorFactory), ImmutableList.of(DOUBLE), new Page(input.build()));
    operatorFactory.noMoreOperators();
    assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.multipleValues(DOUBLE, ImmutableList.of(42.0))))));
}
Also used : Page(io.trino.spi.Page) BlockBuilder(io.trino.spi.block.BlockBuilder) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 78 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFilterSourceOperator method testMultipleColumnsCollectMinMaxRangeWhenTooManyBytes.

@Test
public void testMultipleColumnsCollectMinMaxRangeWhenTooManyBytes() {
    DataSize maxSize = DataSize.of(10, KILOBYTE);
    long maxByteSize = maxSize.toBytes();
    String largeTextA = "A".repeat((int) (maxByteSize / 2) + 1);
    String largeTextB = "B".repeat((int) (maxByteSize / 2) + 1);
    Page largePage = new Page(createStringsBlock(largeTextA), createStringsBlock(largeTextB));
    List<TupleDomain<DynamicFilterId>> expectedTupleDomains = ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.create(ValueSet.ofRanges(range(VARCHAR, utf8Slice(largeTextA), true, utf8Slice(largeTextA), true)), false), new DynamicFilterId("1"), Domain.create(ValueSet.ofRanges(range(VARCHAR, utf8Slice(largeTextB), true, utf8Slice(largeTextB), true)), false))));
    assertDynamicFilters(100, maxSize, 100, ImmutableList.of(VARCHAR, VARCHAR), ImmutableList.of(largePage), expectedTupleDomains);
}
Also used : TupleDomain(io.trino.spi.predicate.TupleDomain) DataSize(io.airlift.units.DataSize) Page(io.trino.spi.Page) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 79 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFilterSourceOperator method testCollectMultipleOperators.

@Test
public void testCollectMultipleOperators() {
    OperatorFactory operatorFactory = createOperatorFactory(channel(0, BIGINT));
    // will finish before noMoreOperators()
    Operator op1 = createOperator(operatorFactory);
    verifyPassthrough(op1, ImmutableList.of(BIGINT), new Page(createLongsBlock(1, 2)), new Page(createLongsBlock(3, 5)));
    // will finish after noMoreOperators()
    Operator op2 = createOperator(operatorFactory);
    operatorFactory.noMoreOperators();
    assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L, 5L))))));
    verifyPassthrough(op2, ImmutableList.of(BIGINT), new Page(createLongsBlock(2, 3)), new Page(createLongsBlock(1, 4)));
    assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L, 5L)))), TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L, 4L))))));
}
Also used : Page(io.trino.spi.Page) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Example 80 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFilterSourceOperator method testCollectRowsNonOrderable.

@Test
public void testCollectRowsNonOrderable() {
    int maxDistinctValues = 100;
    Block block = createColorSequenceBlock(0, maxDistinctValues / 2);
    ImmutableList.Builder<Object> values = ImmutableList.builder();
    for (int position = 0; position < block.getPositionCount(); ++position) {
        values.add(readNativeValue(COLOR, block, position));
    }
    assertDynamicFilters(maxDistinctValues, ImmutableList.of(COLOR), ImmutableList.of(new Page(block)), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.create(ValueSet.copyOf(COLOR, values.build()), false)))));
}
Also used : ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) BlockAssertions.createColorRepeatBlock(io.trino.block.BlockAssertions.createColorRepeatBlock) BlockAssertions.createDoubleRepeatBlock(io.trino.block.BlockAssertions.createDoubleRepeatBlock) Block(io.trino.spi.block.Block) BlockAssertions.createDoublesBlock(io.trino.block.BlockAssertions.createDoublesBlock) BlockAssertions.createColorSequenceBlock(io.trino.block.BlockAssertions.createColorSequenceBlock) BlockAssertions.createLongsBlock(io.trino.block.BlockAssertions.createLongsBlock) BlockAssertions.createLongRepeatBlock(io.trino.block.BlockAssertions.createLongRepeatBlock) BlockAssertions.createLongSequenceBlock(io.trino.block.BlockAssertions.createLongSequenceBlock) BlockAssertions.createDoubleSequenceBlock(io.trino.block.BlockAssertions.createDoubleSequenceBlock) BlockAssertions.createStringsBlock(io.trino.block.BlockAssertions.createStringsBlock) BlockAssertions.createBooleansBlock(io.trino.block.BlockAssertions.createBooleansBlock) Page(io.trino.spi.Page) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test)

Aggregations

DynamicFilterId (io.trino.sql.planner.plan.DynamicFilterId)85 Test (org.testng.annotations.Test)73 PlanNode (io.trino.sql.planner.plan.PlanNode)32 BasePlanTest (io.trino.sql.planner.assertions.BasePlanTest)31 Symbol (io.trino.sql.planner.Symbol)29 TupleDomain (io.trino.spi.predicate.TupleDomain)26 DynamicFilter (io.trino.spi.connector.DynamicFilter)24 ColumnHandle (io.trino.spi.connector.ColumnHandle)21 TestingColumnHandle (io.trino.spi.connector.TestingColumnHandle)20 JoinNode (io.trino.sql.planner.plan.JoinNode)19 Domain (io.trino.spi.predicate.Domain)18 QueryId (io.trino.spi.QueryId)17 StageId (io.trino.execution.StageId)16 TaskId (io.trino.execution.TaskId)15 Page (io.trino.spi.Page)15 Map (java.util.Map)15 ImmutableMap (com.google.common.collect.ImmutableMap)14 Expression (io.trino.sql.tree.Expression)13 VerifyException (com.google.common.base.VerifyException)11 SymbolAllocator (io.trino.sql.planner.SymbolAllocator)11