use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestPhasedExecutionSchedule method createTableScanPlanFragment.
private static PlanFragment createTableScanPlanFragment(String name) {
Symbol symbol = new Symbol("column");
PlanNode planNode = new TableScanNode(new PlanNodeId(name), new TableHandle(new ConnectorId("test"), new TestingTableHandle()), ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingColumnHandle("column")), Optional.empty(), TupleDomain.all(), null);
return createFragment(planNode);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestAggregationOperator method testAggregation.
@Test
public void testAggregation() throws Exception {
MetadataManager metadata = MetadataManager.createTestMetadataManager();
InternalAggregationFunction countVarcharColumn = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("count", AGGREGATE, parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.VARCHAR)));
InternalAggregationFunction maxVarcharColumn = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR)));
List<Page> input = rowPagesBuilder(VARCHAR, BIGINT, VARCHAR, BIGINT, REAL, DOUBLE, VARCHAR).addSequencePage(100, 0, 0, 300, 500, 400, 500, 500).build();
OperatorFactory operatorFactory = new AggregationOperatorFactory(0, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(COUNT.bind(ImmutableList.of(0), Optional.empty()), LONG_SUM.bind(ImmutableList.of(1), Optional.empty()), LONG_AVERAGE.bind(ImmutableList.of(1), Optional.empty()), maxVarcharColumn.bind(ImmutableList.of(2), Optional.empty()), countVarcharColumn.bind(ImmutableList.of(0), Optional.empty()), LONG_SUM.bind(ImmutableList.of(3), Optional.empty()), REAL_SUM.bind(ImmutableList.of(4), Optional.empty()), DOUBLE_SUM.bind(ImmutableList.of(5), Optional.empty()), maxVarcharColumn.bind(ImmutableList.of(6), Optional.empty())));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, DOUBLE, VARCHAR, BIGINT, BIGINT, DOUBLE, VARCHAR).row(100L, 4950L, 49.5, "399", 100L, 54950L, 44950.0f, 54950.0, "599").build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestDistinctLimitOperator method testDistinctLimitValuesLessThanLimit.
@Test(dataProvider = "hashEnabledValues")
public void testDistinctLimitValuesLessThanLimit(boolean hashEnabled) throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
List<Page> input = rowPagesBuilder.addSequencePage(3, 1).addSequencePage(3, 2).build();
OperatorFactory operatorFactory = new DistinctLimitOperator.DistinctLimitOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), Ints.asList(0), 5, rowPagesBuilder.getHashChannel(), joinCompiler);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).row(3L).row(4L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestDistinctLimitOperator method testDistinctLimit.
@Test(dataProvider = "hashEnabledValues")
public void testDistinctLimit(boolean hashEnabled) throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
List<Page> input = rowPagesBuilder.addSequencePage(3, 1).addSequencePage(5, 2).build();
OperatorFactory operatorFactory = new DistinctLimitOperator.DistinctLimitOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), Ints.asList(0), 5, rowPagesBuilder.getHashChannel(), joinCompiler);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).row(3L).row(4L).row(5L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestDistinctLimitOperator method testDistinctLimitWithPageAlignment.
@Test(dataProvider = "hashEnabledValues")
public void testDistinctLimitWithPageAlignment(boolean hashEnabled) throws Exception {
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
List<Page> input = rowPagesBuilder.addSequencePage(3, 1).addSequencePage(3, 2).build();
OperatorFactory operatorFactory = new DistinctLimitOperator.DistinctLimitOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), Ints.asList(0), 3, rowPagesBuilder.getHashChannel(), joinCompiler);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).row(3L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Aggregations