use of com.facebook.presto.sql.planner.plan.DistinctLimitNode in project presto by prestodb.
the class MergeLimitWithDistinct method apply.
@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
if (!(node instanceof LimitNode)) {
return Optional.empty();
}
LimitNode parent = (LimitNode) node;
PlanNode input = lookup.resolve(parent.getSource());
if (!(input instanceof AggregationNode)) {
return Optional.empty();
}
AggregationNode child = (AggregationNode) input;
if (isDistinct(child)) {
return Optional.empty();
}
return Optional.of(new DistinctLimitNode(parent.getId(), child.getSource(), parent.getCount(), false, child.getHashSymbol()));
}
Aggregations