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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations