Search in sources :

Example 1 with NestedLoopJoinOperatorFactory

use of io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method testProbeAndBuildMultiplePages.

@Test
public void testProbeAndBuildMultiplePages() {
    TaskContext taskContext = createTaskContext();
    // build
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("A").row("B").pageBreak().row("C");
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("a").pageBreak().row((String) null).row("b").row("c").pageBreak().row("d").build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = newJoinOperatorFactoryWithCompletedBuild(taskContext, buildPages, ImmutableList.of(0), ImmutableList.of(0));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).row("a", "A").row("a", "B").row("a", "C").row(null, "A").row("b", "A").row("c", "A").row(null, "B").row("b", "B").row("c", "B").row(null, "C").row("b", "C").row("c", "C").row("d", "A").row("d", "B").row("d", "C").build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected);
}
Also used : Type(io.trino.spi.type.Type) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 2 with NestedLoopJoinOperatorFactory

use of io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method testCrossJoinWithNullOnBothSides.

@Test
public void testCrossJoinWithNullOnBothSides() {
    TaskContext taskContext = createTaskContext();
    // build
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("a").row((String) null).row("b").row("c").row((String) null);
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("A").row("B").row((String) null).row("C").build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = newJoinOperatorFactoryWithCompletedBuild(taskContext, buildPages, ImmutableList.of(0), ImmutableList.of(0));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).row("A", "a").row("A", null).row("A", "b").row("A", "c").row("A", null).row("B", "a").row("B", null).row("B", "b").row("B", "c").row("B", null).row(null, "a").row(null, null).row(null, "b").row(null, "c").row(null, null).row("C", "a").row("C", null).row("C", "b").row("C", "c").row("C", null).build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected);
}
Also used : Type(io.trino.spi.type.Type) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 3 with NestedLoopJoinOperatorFactory

use of io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method testColumnReordering.

@Test
public void testColumnReordering() {
    TaskContext taskContext = createTaskContext();
    // build
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT)).addSequencePage(3, 20, 30, 40);
    // probe
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT));
    List<Page> probeInput = probePages.addSequencePage(2, 0, 1000, 2000).build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = newJoinOperatorFactoryWithCompletedBuild(taskContext, buildPages, ImmutableList.of(2, 0, 1), ImmutableList.of(1, 2, 0));
    // expected
    List<Type> expectedProbeTypes = ImmutableList.of(probePages.getTypes().get(2), probePages.getTypes().get(0), probePages.getTypes().get(1));
    List<Type> expectedBuildTypes = ImmutableList.of(probePages.getTypes().get(1), probePages.getTypes().get(2), probePages.getTypes().get(0));
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(expectedProbeTypes, expectedBuildTypes)).row(2000L, "0", 1000L, 30L, 40L, "20").row(2000L, "0", 1000L, 31L, 41L, "21").row(2000L, "0", 1000L, 32L, 42L, "22").row(2001L, "1", 1001L, 30L, 40L, "20").row(2001L, "1", 1001L, 31L, 41L, "21").row(2001L, "1", 1001L, 32L, 42L, "22").build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected);
}
Also used : Type(io.trino.spi.type.Type) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 4 with NestedLoopJoinOperatorFactory

use of io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method testBuildMultiplePages.

@Test
public void testBuildMultiplePages() {
    TaskContext taskContext = createTaskContext();
    // build
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("a").pageBreak().row((String) null).row("b").row("c").pageBreak().row("d");
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("A").row("B").build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = newJoinOperatorFactoryWithCompletedBuild(taskContext, buildPages, ImmutableList.of(0), ImmutableList.of(0));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).row("A", "a").row("B", "a").row("A", null).row("A", "b").row("A", "c").row("B", null).row("B", "b").row("B", "c").row("A", "d").row("B", "d").build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected);
}
Also used : Type(io.trino.spi.type.Type) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 5 with NestedLoopJoinOperatorFactory

use of io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method testCrossJoinWithNullBuild.

@Test
public void testCrossJoinWithNullBuild() {
    TaskContext taskContext = createTaskContext();
    // build
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("a").row((String) null).row((String) null).row("a").row("b");
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("A").row("B").build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = newJoinOperatorFactoryWithCompletedBuild(taskContext, buildPages, ImmutableList.of(0), ImmutableList.of(0));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).row("A", "a").row("A", null).row("A", null).row("A", "a").row("A", "b").row("B", "a").row("B", null).row("B", null).row("B", "a").row("B", "b").build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected);
}
Also used : Type(io.trino.spi.type.Type) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

NestedLoopJoinOperatorFactory (io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)11 RowPagesBuilder (io.trino.RowPagesBuilder)10 TaskContext (io.trino.operator.TaskContext)10 Page (io.trino.spi.Page)10 MaterializedResult (io.trino.testing.MaterializedResult)10 TestingTaskContext (io.trino.testing.TestingTaskContext)10 Test (org.testng.annotations.Test)10 Type (io.trino.spi.type.Type)9 Driver (io.trino.operator.Driver)1 DriverContext (io.trino.operator.DriverContext)1 Operator (io.trino.operator.Operator)1 ValuesOperatorFactory (io.trino.operator.ValuesOperator.ValuesOperatorFactory)1 NestedLoopBuildOperatorFactory (io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory)1 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)1