Search in sources :

Example 1 with DistinctLimitNode

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()));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) DistinctLimitNode(com.facebook.presto.sql.planner.plan.DistinctLimitNode) LimitNode(com.facebook.presto.sql.planner.plan.LimitNode) DistinctLimitNode(com.facebook.presto.sql.planner.plan.DistinctLimitNode) AggregationNode(com.facebook.presto.sql.planner.plan.AggregationNode)

Aggregations

AggregationNode (com.facebook.presto.sql.planner.plan.AggregationNode)1 DistinctLimitNode (com.facebook.presto.sql.planner.plan.DistinctLimitNode)1 LimitNode (com.facebook.presto.sql.planner.plan.LimitNode)1 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)1