Search in sources :

Example 1 with JoinCompiler

use of io.trino.sql.gen.JoinCompiler in project trino by trinodb.

the class TestDistinctLimitOperator method setUp.

@BeforeMethod
public void setUp() {
    executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s"));
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
    driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
    TypeOperators typeOperators = new TypeOperators();
    blockTypeOperators = new BlockTypeOperators(typeOperators);
    joinCompiler = new JoinCompiler(typeOperators);
}
Also used : JoinCompiler(io.trino.sql.gen.JoinCompiler) BlockTypeOperators(io.trino.type.BlockTypeOperators) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with JoinCompiler

use of io.trino.sql.gen.JoinCompiler in project trino by trinodb.

the class TestStreamingAggregationOperator method setUp.

@BeforeMethod
public void setUp() {
    executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s"));
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
    driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
    operatorFactory = StreamingAggregationOperator.createOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BOOLEAN, VARCHAR, BIGINT), ImmutableList.of(VARCHAR), ImmutableList.of(1), ImmutableList.of(COUNT.createAggregatorFactory(SINGLE, ImmutableList.of(0), OptionalInt.empty()), LONG_SUM.createAggregatorFactory(SINGLE, ImmutableList.of(2), OptionalInt.empty())), new JoinCompiler(new TypeOperators()));
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) JoinCompiler(io.trino.sql.gen.JoinCompiler) TypeOperators(io.trino.spi.type.TypeOperators) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with JoinCompiler

use of io.trino.sql.gen.JoinCompiler in project trino by trinodb.

the class TestHashSemiJoinOperator method testSemiJoinOnVarcharType.

@Test(dataProvider = "hashEnabledValues")
public void testSemiJoinOnVarcharType(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), VARCHAR);
    Operator buildOperator = new ValuesOperator(operatorContext, rowPagesBuilder.row("10").row("30").row("30").row("35").row("36").row("37").row("50").build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), rowPagesBuilder.getTypes().get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(typeOperators), blockTypeOperators);
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR, BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), VARCHAR, BIGINT);
    List<Page> probeInput = rowPagesBuilderProbe.addSequencePage(10, 30, 0).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    OperatorFactory joinOperatorFactory = HashSemiJoinOperator.createOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row("30", 0L, true).row("31", 1L, false).row("32", 2L, false).row("33", 3L, false).row("34", 4L, false).row("35", 5L, true).row("36", 6L, true).row("37", 7L, true).row("38", 8L, false).row("39", 9L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.trino.sql.gen.JoinCompiler) RowPagesBuilder(io.trino.RowPagesBuilder) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 4 with JoinCompiler

use of io.trino.sql.gen.JoinCompiler in project trino by trinodb.

the class TestHashSemiJoinOperator method testSemiJoin.

@Test(dataProvider = "hashEnabledValues")
public void testSemiJoin(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
    Operator buildOperator = new ValuesOperator(operatorContext, rowPagesBuilder.row(10L).row(30L).row(30L).row(35L).row(36L).row(37L).row(50L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), rowPagesBuilder.getTypes().get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(typeOperators), blockTypeOperators);
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT, BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT, BIGINT);
    List<Page> probeInput = rowPagesBuilderProbe.addSequencePage(10, 30, 0).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    OperatorFactory joinOperatorFactory = HashSemiJoinOperator.createOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(30L, 0L, true).row(31L, 1L, false).row(32L, 2L, false).row(33L, 3L, false).row(34L, 4L, false).row(35L, 5L, true).row(36L, 6L, true).row(37L, 7L, true).row(38L, 8L, false).row(39L, 9L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.trino.sql.gen.JoinCompiler) RowPagesBuilder(io.trino.RowPagesBuilder) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 5 with JoinCompiler

use of io.trino.sql.gen.JoinCompiler in project trino by trinodb.

the class TestHashSemiJoinOperator method testProbeSideNulls.

@Test(dataProvider = "hashEnabledValues")
public void testProbeSideNulls(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), buildTypes);
    Operator buildOperator = new ValuesOperator(operatorContext, rowPagesBuilder.row(0L).row(1L).row(3L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), buildTypes.get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(typeOperators), blockTypeOperators);
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = rowPagesBuilderProbe.row(0L).row((Object) null).row(1L).row(2L).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    OperatorFactory joinOperatorFactory = HashSemiJoinOperator.createOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(0L, true).row(null, null).row(1L, true).row(2L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.trino.sql.gen.JoinCompiler) RowPagesBuilder(io.trino.RowPagesBuilder) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

JoinCompiler (io.trino.sql.gen.JoinCompiler)17 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)12 Test (org.testng.annotations.Test)8 RowPagesBuilder (io.trino.RowPagesBuilder)7 SetBuilderOperatorFactory (io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory)7 Page (io.trino.spi.Page)7 Type (io.trino.spi.type.Type)7 TypeOperators (io.trino.spi.type.TypeOperators)6 MaterializedResult (io.trino.testing.MaterializedResult)6 BlockTypeOperators (io.trino.type.BlockTypeOperators)5 GroupByHashPageIndexerFactory (io.trino.operator.GroupByHashPageIndexerFactory)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 HashAggregationOperatorFactory (io.trino.operator.HashAggregationOperator.HashAggregationOperatorFactory)2 OperatorFactory (io.trino.operator.OperatorFactory)2 SchemaTableName (io.trino.spi.connector.SchemaTableName)2 TestingNodeManager (io.trino.testing.TestingNodeManager)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 HostAndPort (com.google.common.net.HostAndPort)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1