use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestTopNOperator 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).pageBreak().row(5L, 0.5).row(4L, 0.41).row(6L, 0.6).pageBreak().build();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), 2, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE).row(6L, 0.6).row(5L, 0.5).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestTopNOperator method testMultiFieldKey.
@Test
public void testMultiFieldKey() throws Exception {
List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).row("a", 1L).row("b", 2L).pageBreak().row("f", 3L).row("a", 4L).pageBreak().row("d", 5L).row("d", 7L).row("e", 6L).build();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR, BIGINT), 3, ImmutableList.of(0, 1), ImmutableList.of(DESC_NULLS_LAST, DESC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("f", 3L).row("e", 6L).row("d", 7L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestTopNRowNumberOperator method testTopNRowNumberPartitioned.
@Test(dataProvider = "hashEnabledValues")
public void testTopNRowNumberPartitioned(boolean hashEnabled) throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT, DOUBLE);
List<Page> input = rowPagesBuilder.row(1L, 0.3).row(2L, 0.2).row(3L, 0.1).row(3L, 0.91).pageBreak().row(1L, 0.4).pageBreak().row(1L, 0.5).row(1L, 0.6).row(2L, 0.7).row(2L, 0.8).pageBreak().row(2L, 0.9).build();
TopNRowNumberOperatorFactory operatorFactory = new TopNRowNumberOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), Ints.asList(1, 0), Ints.asList(0), ImmutableList.of(BIGINT), Ints.asList(1), ImmutableList.of(SortOrder.ASC_NULLS_LAST), 3, false, Optional.empty(), 10, joinCompiler);
MaterializedResult expected = resultBuilder(driverContext.getSession(), DOUBLE, BIGINT, BIGINT).row(0.3, 1L, 1L).row(0.4, 1L, 2L).row(0.5, 1L, 3L).row(0.2, 2L, 1L).row(0.7, 2L, 2L).row(0.8, 2L, 3L).row(0.1, 3L, 1L).row(0.91, 3L, 2L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId 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.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestGroupIdOperator method testGroupId.
public void testGroupId() throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(false, ImmutableList.of(), BIGINT, VARCHAR, BOOLEAN, BIGINT);
List<Page> input = rowPagesBuilder.addSequencePage(3, 100, 400, 0, 1000).addSequencePage(3, 200, 500, 0, 1100).build();
GroupIdOperatorFactory operatorFactory = new GroupIdOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR, BOOLEAN, BIGINT, BIGINT, BIGINT), ImmutableList.of(ImmutableMap.of(0, 1, 1, 2, 3, 0), ImmutableMap.of(2, 3, 3, 0)));
MaterializedResult expected = resultBuilder(driverContext.getSession(), VARCHAR, BOOLEAN, BIGINT, BIGINT, BIGINT).row("400", true, null, 100L, 0L).row("401", false, null, 101L, 0L).row("402", true, null, 102L, 0L).row("500", true, null, 200L, 0L).row("501", false, null, 201L, 0L).row("502", true, null, 202L, 0L).row(null, null, 1000L, 100L, 1L).row(null, null, 1001L, 101L, 1L).row(null, null, 1002L, 102L, 1L).row(null, null, 1100L, 200L, 1L).row(null, null, 1101L, 201L, 1L).row(null, null, 1102L, 202L, 1L).build();
assertOperatorEqualsIgnoreOrder(operatorFactory, driverContext, input, expected);
}
Aggregations