use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class FunctionAssertions method compileScanFilterProject.
private static SourceOperatorFactory compileScanFilterProject(SqlFunctionProperties sqlFunctionProperties, Optional<RowExpression> filter, RowExpression projection, ExpressionCompiler compiler) {
try {
Supplier<CursorProcessor> cursorProcessor = compiler.compileCursorProcessor(sqlFunctionProperties, filter, ImmutableList.of(projection), SOURCE_ID);
Supplier<PageProcessor> pageProcessor = compiler.compilePageProcessor(sqlFunctionProperties, filter, ImmutableList.of(projection));
return new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), SOURCE_ID, PAGE_SOURCE_PROVIDER, cursorProcessor, pageProcessor, new TableHandle(new ConnectorId("test"), new ConnectorTableHandle() {
}, new ConnectorTransactionHandle() {
}, Optional.empty()), ImmutableList.of(), ImmutableList.of(projection.getType()), Optional.empty(), new DataSize(0, BYTE), 0);
} catch (Throwable e) {
if (e instanceof UncheckedExecutionException) {
e = e.getCause();
}
throw new RuntimeException("Error compiling filter " + filter + ": " + e.getMessage(), e);
}
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestPushPartialAggregationThroughExchange method testPartialAggregationEnabledWhenNotConfident.
@Test
public void testPartialAggregationEnabledWhenNotConfident() {
tester().assertThat(new PushPartialAggregationThroughExchange(getFunctionManager())).setSystemProperty(PARTIAL_AGGREGATION_STRATEGY, "AUTOMATIC").on(p -> {
VariableReferenceExpression a = p.variable("a", DOUBLE);
VariableReferenceExpression b = p.variable("b", DOUBLE);
return p.aggregation(ab -> ab.source(p.exchange(e -> e.addSource(p.values(new PlanNodeId("values"), a, b)).addInputsSet(a, b).singleDistributionPartitioningScheme(a, b))).addAggregation(p.variable("SUM", DOUBLE), expression("SUM(a)"), ImmutableList.of(DOUBLE)).singleGroupingSet(b).step(PARTIAL));
}).overrideStats("values", PlanNodeStatsEstimate.builder().setOutputRowCount(1000).addVariableStatistics(variable("b", DOUBLE), new VariableStatsEstimate(0, 100, 0, 8, 800)).setConfident(false).build()).matches(exchange(project(aggregation(ImmutableMap.of("SUM", functionCall("sum", ImmutableList.of("a"))), PARTIAL, values("a", "b")))));
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class TestPushPartialAggregationThroughExchange method testNoPartialAggregationWhenReductionBelowThreshold.
@Test
public void testNoPartialAggregationWhenReductionBelowThreshold() {
tester().assertThat(new PushPartialAggregationThroughExchange(getFunctionManager())).setSystemProperty(PARTIAL_AGGREGATION_STRATEGY, "AUTOMATIC").on(p -> {
VariableReferenceExpression a = p.variable("a", DOUBLE);
VariableReferenceExpression b = p.variable("b", DOUBLE);
return p.aggregation(ab -> ab.source(p.exchange(e -> e.addSource(p.values(new PlanNodeId("values"), a, b)).addInputsSet(a, b).singleDistributionPartitioningScheme(a, b))).addAggregation(p.variable("SUM", DOUBLE), expression("SUM(a)"), ImmutableList.of(DOUBLE)).singleGroupingSet(b).step(SINGLE));
}).overrideStats("values", PlanNodeStatsEstimate.builder().setOutputRowCount(1000).addVariableStatistics(variable("b", DOUBLE), new VariableStatsEstimate(0, 100, 0, 8, 800)).setConfident(true).build()).doesNotFire();
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class CountAggregationBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey");
FunctionAndTypeManager functionAndTypeManager = localQueryRunner.getMetadata().getFunctionAndTypeManager();
InternalAggregationFunction countFunction = functionAndTypeManager.getAggregateFunctionImplementation(functionAndTypeManager.lookupFunction("count", fromTypes(BIGINT)));
AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(countFunction.bind(ImmutableList.of(0), Optional.empty())), false);
return ImmutableList.of(tableScanOperator, aggregationOperator);
}
use of com.facebook.presto.spi.plan.PlanNodeId in project presto by prestodb.
the class SqlTask method createTaskInfo.
private TaskInfo createTaskInfo(TaskHolder taskHolder) {
TaskStats taskStats = getTaskStats(taskHolder);
Set<PlanNodeId> noMoreSplits = getNoMoreSplits(taskHolder);
MetadataUpdates metadataRequests = getMetadataUpdateRequests(taskHolder);
TaskStatus taskStatus = createTaskStatus(taskHolder);
return new TaskInfo(taskStateMachine.getTaskId(), taskStatus, lastHeartbeat.get(), outputBuffer.getInfo(), noMoreSplits, taskStats, needsPlan.get(), metadataRequests, nodeId);
}
Aggregations