Search in sources :

Example 1 with FilterNode

use of com.facebook.presto.sql.planner.plan.FilterNode in project presto by prestodb.

the class TestSimplifyExpressions method simplifyExpressions.

private static Expression simplifyExpressions(Expression expression) {
    PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
    FilterNode filterNode = new FilterNode(planNodeIdAllocator.getNextId(), new ValuesNode(planNodeIdAllocator.getNextId(), emptyList(), emptyList()), expression);
    FilterNode simplifiedNode = (FilterNode) SIMPLIFIER.optimize(filterNode, TEST_SESSION, booleanSymbolTypeMapFor(expression), new SymbolAllocator(), planNodeIdAllocator);
    return simplifiedNode.getPredicate();
}
Also used : SymbolAllocator(com.facebook.presto.sql.planner.SymbolAllocator) ValuesNode(com.facebook.presto.sql.planner.plan.ValuesNode) PlanNodeIdAllocator(com.facebook.presto.sql.planner.PlanNodeIdAllocator) FilterNode(com.facebook.presto.sql.planner.plan.FilterNode)

Example 2 with FilterNode

use of com.facebook.presto.sql.planner.plan.FilterNode in project presto by prestodb.

the class MergeFilters method apply.

@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
    if (!(node instanceof FilterNode)) {
        return Optional.empty();
    }
    FilterNode parent = (FilterNode) node;
    PlanNode source = lookup.resolve(parent.getSource());
    if (!(source instanceof FilterNode)) {
        return Optional.empty();
    }
    FilterNode child = (FilterNode) source;
    return Optional.of(new FilterNode(parent.getId(), child.getSource(), combineConjuncts(child.getPredicate(), parent.getPredicate())));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) FilterNode(com.facebook.presto.sql.planner.plan.FilterNode)

Example 3 with FilterNode

use of com.facebook.presto.sql.planner.plan.FilterNode in project presto by prestodb.

the class FilterMatcher method detailMatches.

@Override
public MatchResult detailMatches(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
    checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
    FilterNode filterNode = (FilterNode) node;
    ExpressionVerifier verifier = new ExpressionVerifier(symbolAliases);
    return new MatchResult(verifier.process(filterNode.getPredicate(), predicate));
}
Also used : FilterNode(com.facebook.presto.sql.planner.plan.FilterNode)

Aggregations

FilterNode (com.facebook.presto.sql.planner.plan.FilterNode)3 PlanNodeIdAllocator (com.facebook.presto.sql.planner.PlanNodeIdAllocator)1 SymbolAllocator (com.facebook.presto.sql.planner.SymbolAllocator)1 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)1 ValuesNode (com.facebook.presto.sql.planner.plan.ValuesNode)1