use of com.facebook.presto.spi.plan.AggregationNode.Aggregation in project presto by prestodb.
the class AddIntermediateAggregations method outputsAsInputs.
/**
* Rewrite assignments so that inputs are in terms of the output symbols.
* <p>
* Example:
* 'a' := sum('b') => 'a' := sum('a')
* 'a' := count(*) => 'a' := count('a')
*/
private static Map<VariableReferenceExpression, Aggregation> outputsAsInputs(Map<VariableReferenceExpression, Aggregation> assignments) {
ImmutableMap.Builder<VariableReferenceExpression, Aggregation> builder = ImmutableMap.builder();
for (Map.Entry<VariableReferenceExpression, Aggregation> entry : assignments.entrySet()) {
VariableReferenceExpression output = entry.getKey();
Aggregation aggregation = entry.getValue();
checkState(!aggregation.getOrderBy().isPresent(), "Intermediate aggregation does not support ORDER BY");
builder.put(output, new Aggregation(new CallExpression(aggregation.getCall().getSourceLocation(), aggregation.getCall().getDisplayName(), aggregation.getCall().getFunctionHandle(), aggregation.getCall().getType(), ImmutableList.of(output)), Optional.empty(), Optional.empty(), false, // No mask for INTERMEDIATE
Optional.empty()));
}
return builder.build();
}
Aggregations