Search in sources :

Example 1 with TopNRowNumberOperatorFactory

use of com.facebook.presto.operator.TopNRowNumberOperator.TopNRowNumberOperatorFactory 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);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) RowPagesBuilder(com.facebook.presto.RowPagesBuilder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) TopNRowNumberOperatorFactory(com.facebook.presto.operator.TopNRowNumberOperator.TopNRowNumberOperatorFactory) Test(org.testng.annotations.Test)

Example 2 with TopNRowNumberOperatorFactory

use of com.facebook.presto.operator.TopNRowNumberOperator.TopNRowNumberOperatorFactory in project presto by prestodb.

the class TestTopNRowNumberOperator method testTopNRowNumberUnPartitioned.

@Test
public void testTopNRowNumberUnPartitioned() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).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(), ImmutableList.of(), 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.1, 3L, 1L).row(0.2, 2L, 2L).row(0.3, 1L, 3L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) TopNRowNumberOperatorFactory(com.facebook.presto.operator.TopNRowNumberOperator.TopNRowNumberOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

TopNRowNumberOperatorFactory (com.facebook.presto.operator.TopNRowNumberOperator.TopNRowNumberOperatorFactory)2 Page (com.facebook.presto.spi.Page)2 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 Test (org.testng.annotations.Test)2 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)1