use of com.facebook.presto.sql.planner.optimizations.ScalarAggregationToJoinRewriter in project presto by prestodb.
the class TransformCorrelatedScalarAggregationToJoin method apply.
@Override
public Result apply(LateralJoinNode lateralJoinNode, Captures captures, Context context) {
PlanNode subquery = lateralJoinNode.getSubquery();
if (!isScalar(subquery, context.getLookup())) {
return Result.empty();
}
Optional<AggregationNode> aggregation = findAggregation(subquery, context.getLookup());
if (!(aggregation.isPresent() && aggregation.get().getGroupingKeys().isEmpty())) {
return Result.empty();
}
ScalarAggregationToJoinRewriter rewriter = new ScalarAggregationToJoinRewriter(functionAndTypeManager, context.getVariableAllocator(), context.getIdAllocator(), context.getLookup());
PlanNode rewrittenNode = rewriter.rewriteScalarAggregation(lateralJoinNode, aggregation.get());
if (rewrittenNode instanceof LateralJoinNode) {
return Result.empty();
}
return Result.ofPlanNode(rewrittenNode);
}
Aggregations