Search in sources :

Example 91 with PlanNodeId

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

the class TestTableWriterOperator method createTableWriterOperator.

private Operator createTableWriterOperator(BlockingPageSink blockingPageSink) {
    PageSinkManager pageSinkManager = new PageSinkManager();
    pageSinkManager.addConnectorPageSinkProvider(CONNECTOR_ID, new ConstantPageSinkProvider(blockingPageSink));
    return createTableWriterOperator(pageSinkManager, new DevNullOperatorFactory(1, new PlanNodeId("test")), ImmutableList.of(BIGINT, VARBINARY, VARBINARY));
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) DevNullOperatorFactory(com.facebook.presto.operator.DevNullOperator.DevNullOperatorFactory) PageSinkManager(com.facebook.presto.split.PageSinkManager)

Example 92 with PlanNodeId

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

the class TestTopNOperator method testSingleFieldKey.

@Test
public void testSingleFieldKey() {
    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));
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE).row(6L, 0.6).row(5L, 0.5).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) Page(com.facebook.presto.common.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 93 with PlanNodeId

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

the class TestTopNOperator method testLimitZero.

@Test
public void testLimitZero() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT).row(1L).build();
    TopNOperatorFactory factory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 0, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST));
    try (Operator operator = factory.createOperator(driverContext)) {
        assertEquals(operator.isFinished(), true);
        assertEquals(operator.needsInput(), false);
        assertEquals(operator.getOutput(), null);
    }
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) Page(com.facebook.presto.common.Page) Test(org.testng.annotations.Test)

Example 94 with PlanNodeId

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

the class TestTopNOperator method testMultiFieldKey.

@Test
public void testMultiFieldKey() {
    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));
    MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("f", 3L).row("e", 6L).row("d", 7L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) Page(com.facebook.presto.common.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 95 with PlanNodeId

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

the class TestTopNOperator method testExceedMemoryLimit.

@Test
public void testExceedMemoryLimit() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT).row(1L).build();
    DriverContext smallDiverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION, new DataSize(1, BYTE)).addPipelineContext(0, true, true, false).addDriverContext();
    TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST));
    try (Operator operator = operatorFactory.createOperator(smallDiverContext)) {
        operator.addInput(input.get(0));
        fail("must fail because of exceeding local memory limit");
    } catch (ExceededMemoryLimitException ignore) {
    }
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) DataSize(io.airlift.units.DataSize) Page(com.facebook.presto.common.Page) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException) Test(org.testng.annotations.Test)

Aggregations

PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)204 Test (org.testng.annotations.Test)123 Page (com.facebook.presto.common.Page)83 MaterializedResult (com.facebook.presto.testing.MaterializedResult)52 Type (com.facebook.presto.common.type.Type)47 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)43 ImmutableList (com.google.common.collect.ImmutableList)43 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)39 DataSize (io.airlift.units.DataSize)39 Optional (java.util.Optional)35 ImmutableMap (com.google.common.collect.ImmutableMap)34 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)25 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)23 VariableStatsEstimate (com.facebook.presto.cost.VariableStatsEstimate)23 Split (com.facebook.presto.metadata.Split)23 OperatorFactory (com.facebook.presto.operator.OperatorFactory)23 PlanNodeStatsEstimate (com.facebook.presto.cost.PlanNodeStatsEstimate)22 RowExpression (com.facebook.presto.spi.relation.RowExpression)21 PlanMatchPattern.values (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values)21 JOIN_DISTRIBUTION_TYPE (com.facebook.presto.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)20