Search in sources :

Example 96 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class PushPredicateIntoTableScan method apply.

@Override
public Result apply(FilterNode filterNode, Captures captures, Context context) {
    TableScanNode tableScan = captures.get(TABLE_SCAN);
    Optional<PlanNode> rewritten = pushPredicateIntoTableScan(tableScan, filterNode.getPredicate(), false, context.getSession(), context.getIdAllocator(), context.getSymbolAllocator(), metadata, new RowExpressionDomainTranslator(metadata), pushPartitionsOnly);
    if (!rewritten.isPresent() || arePlansSame(filterNode, tableScan, rewritten.get())) {
        return Result.empty();
    }
    return Result.ofPlanNode(rewritten.get());
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) RowExpressionDomainTranslator(io.prestosql.sql.relational.RowExpressionDomainTranslator)

Example 97 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class PushTopNThroughOuterJoin method apply.

@Override
public Result apply(TopNNode parent, Captures captures, Context context) {
    JoinNode joinNode = captures.get(JOIN_CHILD);
    List<Symbol> orderBySymbols = parent.getOrderingScheme().getOrderBy();
    PlanNode left = joinNode.getLeft();
    PlanNode right = joinNode.getRight();
    JoinNode.Type type = joinNode.getType();
    if ((type == LEFT) && ImmutableSet.copyOf(left.getOutputSymbols()).containsAll(orderBySymbols) && !isAtMost(left, context.getLookup(), parent.getCount())) {
        return Result.ofPlanNode(joinNode.replaceChildren(ImmutableList.of(parent.replaceChildren(ImmutableList.of(left)), right)));
    }
    if ((type == RIGHT) && ImmutableSet.copyOf(right.getOutputSymbols()).containsAll(orderBySymbols) && !isAtMost(right, context.getLookup(), parent.getCount())) {
        return Result.ofPlanNode(joinNode.replaceChildren(ImmutableList.of(left, parent.replaceChildren(ImmutableList.of(right)))));
    }
    return Result.empty();
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol)

Example 98 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class PushTopNThroughProject method apply.

@Override
public Result apply(TopNNode parent, Captures captures, Context context) {
    ProjectNode projectNode = captures.get(PROJECT_CHILD);
    // do not push topN between projection and filter(table scan) so that they can be merged into a PageProcessor
    PlanNode projectSource = context.getLookup().resolve(projectNode.getSource());
    if (projectSource instanceof FilterNode) {
        PlanNode filterSource = context.getLookup().resolve(((FilterNode) projectSource).getSource());
        if (filterSource instanceof TableScanNode) {
            return Result.empty();
        }
    }
    Optional<SymbolMapper> symbolMapper = symbolMapper(parent.getOrderingScheme().getOrderBy(), projectNode.getAssignments());
    if (!symbolMapper.isPresent()) {
        return Result.empty();
    }
    TopNNode mappedTopN = symbolMapper.get().map(parent, projectNode.getSource(), context.getIdAllocator().getNextId());
    return Result.ofPlanNode(projectNode.replaceChildren(ImmutableList.of(mappedTopN)));
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) SymbolMapper(io.prestosql.sql.planner.optimizations.SymbolMapper) FilterNode(io.prestosql.spi.plan.FilterNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) TopNNode(io.prestosql.spi.plan.TopNNode)

Example 99 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class PushAggregationThroughOuterJoin method getInnerTable.

private static PlanNode getInnerTable(JoinNode join) {
    checkState(join.getType() == JoinNode.Type.LEFT || join.getType() == JoinNode.Type.RIGHT, "expected LEFT or RIGHT JOIN");
    PlanNode innerNode;
    if (join.getType().equals(JoinNode.Type.LEFT)) {
        innerNode = join.getRight();
    } else {
        innerNode = join.getLeft();
    }
    return innerNode;
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode)

Example 100 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class PushAggregationThroughOuterJoin method getOuterTable.

private static PlanNode getOuterTable(JoinNode join) {
    checkState(join.getType() == JoinNode.Type.LEFT || join.getType() == JoinNode.Type.RIGHT, "expected LEFT or RIGHT JOIN");
    PlanNode outerNode;
    if (join.getType().equals(JoinNode.Type.LEFT)) {
        outerNode = join.getLeft();
    } else {
        outerNode = join.getRight();
    }
    return outerNode;
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode)

Aggregations

PlanNode (io.prestosql.spi.plan.PlanNode)241 Test (org.testng.annotations.Test)100 Symbol (io.prestosql.spi.plan.Symbol)98 RowExpression (io.prestosql.spi.relation.RowExpression)52 ImmutableList (com.google.common.collect.ImmutableList)49 ProjectNode (io.prestosql.spi.plan.ProjectNode)46 Expression (io.prestosql.sql.tree.Expression)46 TableScanNode (io.prestosql.spi.plan.TableScanNode)45 JoinNode (io.prestosql.spi.plan.JoinNode)42 Optional (java.util.Optional)42 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)41 FilterNode (io.prestosql.spi.plan.FilterNode)39 CallExpression (io.prestosql.spi.relation.CallExpression)39 ImmutableMap (com.google.common.collect.ImmutableMap)38 List (java.util.List)38 Map (java.util.Map)36 AggregationNode (io.prestosql.spi.plan.AggregationNode)35 BasePlanTest (io.prestosql.sql.planner.assertions.BasePlanTest)34 Assignments (io.prestosql.spi.plan.Assignments)33 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)32