Search in sources :

Example 81 with PlanNodeId

use of com.facebook.presto.sql.planner.plan.PlanNodeId 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 82 with PlanNodeId

use of com.facebook.presto.sql.planner.plan.PlanNodeId 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 83 with PlanNodeId

use of com.facebook.presto.sql.planner.plan.PlanNodeId 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)

Example 84 with PlanNodeId

use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.

the class TestExchangeOperator method createExchangeOperator.

private SourceOperator createExchangeOperator() {
    ExchangeOperatorFactory operatorFactory = new ExchangeOperatorFactory(0, new PlanNodeId("test"), exchangeClientSupplier, SERDE_FACTORY, TYPES);
    DriverContext driverContext = createTaskContext(executor, TEST_SESSION).addPipelineContext(0, true, true).addDriverContext();
    SourceOperator operator = operatorFactory.createOperator(driverContext);
    assertEquals(operator.getOperatorContext().getOperatorStats().getSystemMemoryReservation().toBytes(), 0);
    return operator;
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) ExchangeOperatorFactory(com.facebook.presto.operator.ExchangeOperator.ExchangeOperatorFactory)

Example 85 with PlanNodeId

use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.

the class TestOrderByOperator method testSingleFieldKey.

@Test
public void testSingleFieldKey() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(1L, 0.1).row(2L, 0.2).pageBreak().row(-1L, -0.1).row(4L, 0.4).build();
    OrderByOperatorFactory operatorFactory = new OrderByOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), ImmutableList.of(1), 10, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), new PagesIndex.TestingFactory());
    MaterializedResult expected = resultBuilder(driverContext.getSession(), DOUBLE).row(-0.1).row(0.1).row(0.2).row(0.4).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) OrderByOperatorFactory(com.facebook.presto.operator.OrderByOperator.OrderByOperatorFactory) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)118 Test (org.testng.annotations.Test)76 Page (com.facebook.presto.spi.Page)70 MaterializedResult (com.facebook.presto.testing.MaterializedResult)59 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)46 Type (com.facebook.presto.spi.type.Type)40 DataSize (io.airlift.units.DataSize)25 TestingTaskContext (com.facebook.presto.testing.TestingTaskContext)24 HashBuilderOperatorFactory (com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory)16 ValuesOperatorFactory (com.facebook.presto.operator.ValuesOperator.ValuesOperatorFactory)15 ImmutableList (com.google.common.collect.ImmutableList)15 LocalExchangeSinkOperatorFactory (com.facebook.presto.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory)13 LocalExchangeSourceOperatorFactory (com.facebook.presto.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory)13 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)11 List (java.util.List)11 Split (com.facebook.presto.metadata.Split)10 OperatorAssertion.toMaterializedResult (com.facebook.presto.operator.OperatorAssertion.toMaterializedResult)10 OperatorFactory (com.facebook.presto.operator.OperatorFactory)10 Block (com.facebook.presto.spi.block.Block)10 Optional (java.util.Optional)10