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());
}
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();
}
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)));
}
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;
}
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;
}
Aggregations