Search in sources :

Example 6 with NestedLoopJoinOperatorFactory

use of com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project presto by prestodb.

the class TestNestedLoopJoinOperator method testEmptyBuildPage.

@Test
public void testEmptyBuildPage() throws Exception {
    TaskContext taskContext = createTaskContext();
    // build
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).pageBreak();
    NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("A").row("B").pageBreak().build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) TestingTaskContext(com.facebook.presto.testing.TestingTaskContext) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 7 with NestedLoopJoinOperatorFactory

use of com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project presto by prestodb.

the class TestNestedLoopJoinOperator method testNestedLoopJoin.

@Test
public void testNestedLoopJoin() throws Exception {
    TaskContext taskContext = createTaskContext();
    // build
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT)).addSequencePage(3, 20, 30, 40);
    NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
    // probe
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT));
    List<Page> probeInput = probePages.addSequencePage(2, 0, 1000, 2000).build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR, BIGINT, BIGINT));
    // expected
    MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probePages.getTypes(), buildPages.getTypes())).row("0", 1000L, 2000L, "20", 30L, 40L).row("0", 1000L, 2000L, "21", 31L, 41L).row("0", 1000L, 2000L, "22", 32L, 42L).row("1", 1001L, 2001L, "20", 30L, 40L).row("1", 1001L, 2001L, "21", 31L, 41L).row("1", 1001L, 2001L, "22", 32L, 42L).build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
    // Test probe pages has more rows
    buildPages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT)).addSequencePage(2, 20, 30, 40);
    nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
    joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR, BIGINT, BIGINT));
    // probe
    probePages = rowPagesBuilder(ImmutableList.of(VARCHAR, BIGINT, BIGINT));
    probeInput = probePages.addSequencePage(3, 0, 1000, 2000).build();
    // expected
    expected = resultBuilder(taskContext.getSession(), concat(probePages.getTypes(), buildPages.getTypes())).row("0", 1000L, 2000L, "20", 30L, 40L).row("1", 1001L, 2001L, "20", 30L, 40L).row("2", 1002L, 2002L, "20", 30L, 40L).row("0", 1000L, 2000L, "21", 31L, 41L).row("1", 1001L, 2001L, "21", 31L, 41L).row("2", 1002L, 2002L, "21", 31L, 41L).build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) TestingTaskContext(com.facebook.presto.testing.TestingTaskContext) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 8 with NestedLoopJoinOperatorFactory

use of com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project presto by prestodb.

the class TestNestedLoopJoinOperator method testCrossJoinWithNullOnBothSides.

@Test
public void testCrossJoinWithNullOnBothSides() throws Exception {
    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);
    NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
    // 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 = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR));
    // 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).addDriverContext(), probeInput, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) TestingTaskContext(com.facebook.presto.testing.TestingTaskContext) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 9 with NestedLoopJoinOperatorFactory

use of com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory in project presto by prestodb.

the class TestNestedLoopJoinOperator method testBuildMultiplePages.

@Test
public void testBuildMultiplePages() throws Exception {
    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");
    NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
    // probe
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
    List<Page> probeInput = probePages.row("A").row("B").build();
    NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR));
    // 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).addDriverContext(), probeInput, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) TestingTaskContext(com.facebook.presto.testing.TestingTaskContext) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

RowPagesBuilder (com.facebook.presto.RowPagesBuilder)9 NestedLoopJoinOperatorFactory (com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)9 Page (com.facebook.presto.spi.Page)9 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)9 MaterializedResult (com.facebook.presto.testing.MaterializedResult)9 TestingTaskContext (com.facebook.presto.testing.TestingTaskContext)9 Test (org.testng.annotations.Test)9 Type (com.facebook.presto.spi.type.Type)8