use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestUnnestOperator method testUnnestNonNumericDoubles.
@Test
public void testUnnestNonNumericDoubles() throws Exception {
MetadataManager metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(double)"));
Type mapType = metadata.getType(parseTypeSignature("map(bigint,double)"));
List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(DOUBLE, NEGATIVE_INFINITY, POSITIVE_INFINITY, NaN), mapBlockOf(BIGINT, DOUBLE, ImmutableMap.of(1, NEGATIVE_INFINITY, 2, POSITIVE_INFINITY, 3, NaN))).build();
OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE, BIGINT, DOUBLE).row(1L, NEGATIVE_INFINITY, 1L, NEGATIVE_INFINITY).row(1L, POSITIVE_INFINITY, 2L, POSITIVE_INFINITY).row(1L, NaN, 3L, NaN).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestMergeHashSort method testPageRewriteIterator.
@Test
public void testPageRewriteIterator() {
ImmutableList<Type> types = ImmutableList.of(BIGINT, BIGINT);
RowPagesBuilder pagesBuilder = rowPagesBuilder(types);
pagesBuilder.row(0, 42);
pagesBuilder.row(0, 43);
pagesBuilder.pageBreak();
pagesBuilder.row(0, 44);
pagesBuilder.row(1, 45);
pagesBuilder.pageBreak();
pagesBuilder.row(2, 46);
Iterator<Page> rewriterIterator = new MergeHashSort.PageRewriteIterator(new InterpretedHashGenerator(ImmutableList.of(BIGINT), new int[] { 0 }), types, new MergeHashSort.SingleChannelPagePositions(pagesBuilder.build().iterator()));
List<Page> pages = Lists.newArrayList(rewriterIterator);
assertEquals(pages.size(), 1);
List<Page> expectedPages = rowPagesBuilder(types).row(0, 42).row(0, 43).row(0, 44).row(1, 45).row(2, 46).build();
assertPageEquals(types, pages.get(0), expectedPages.get(0));
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestNestedLoopJoinOperator method testProbeMultiplePages.
@Test
public void testProbeMultiplePages() throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("A").row("B");
NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
// 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 = 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", "B").row(null, "A").row("b", "A").row("c", "A").row(null, "B").row("b", "B").row("c", "B").row("d", "A").row("d", "B").build();
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestNestedLoopJoinOperator method testEmptyProbePage.
@Test
public void testEmptyProbePage() throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("A").row("B").pageBreak().row("C");
NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
// probe
List<Type> probeTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
List<Page> probeInput = probePages.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);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestNestedLoopJoinOperator method testCrossJoinWithNullProbe.
@Test
public void testCrossJoinWithNullProbe() throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("a").row("b");
NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
// probe
List<Type> probeTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
List<Page> probeInput = probePages.row("A").row((String) null).row((String) null).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(null, "a").row(null, "a").row("A", "a").row("B", "a").row("A", "b").row(null, "b").row(null, "b").row("A", "b").row("B", "b").build();
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
Aggregations