use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class RelationPlanner method visitExcept.
@Override
protected RelationPlan visitExcept(Except node, Void context) {
checkArgument(!node.getRelations().isEmpty(), "No relations specified for EXCEPT");
SetOperationPlan setOperationPlan = process(node);
PlanNode planNode = new ExceptNode(idAllocator.getNextId(), setOperationPlan.getSources(), setOperationPlan.getSymbolMapping(), ImmutableList.copyOf(setOperationPlan.getSymbolMapping().keySet()));
return new RelationPlan(planNode, analysis.getScope(node), planNode.getOutputSymbols());
}
use of com.facebook.presto.sql.planner.plan.PlanNode 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())));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class PushLimitThroughMarkDistinct 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 child = lookup.resolve(parent.getSource());
if (!(child instanceof MarkDistinctNode)) {
return Optional.empty();
}
return Optional.of(transpose(parent, child));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class PushLimitThroughProject 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 child = lookup.resolve(parent.getSource());
if (!(child instanceof ProjectNode)) {
return Optional.empty();
}
return Optional.of(transpose(parent, child));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class JoinGraph method joinWith.
private JoinGraph joinWith(JoinGraph other, List<JoinNode.EquiJoinClause> joinClauses, Context context, PlanNodeId newRoot) {
for (PlanNode node : other.nodes) {
checkState(!edges.containsKey(node.getId()), format("Node [%s] appeared in two JoinGraphs", node));
}
List<PlanNode> nodes = ImmutableList.<PlanNode>builder().addAll(this.nodes).addAll(other.nodes).build();
ImmutableMultimap.Builder<PlanNodeId, Edge> edges = ImmutableMultimap.<PlanNodeId, Edge>builder().putAll(this.edges).putAll(other.edges);
List<Expression> joinedFilters = ImmutableList.<Expression>builder().addAll(this.filters).addAll(other.filters).build();
for (JoinNode.EquiJoinClause edge : joinClauses) {
Symbol leftSymbol = edge.getLeft();
Symbol rightSymbol = edge.getRight();
checkState(context.containsSymbol(leftSymbol));
checkState(context.containsSymbol(rightSymbol));
PlanNode left = context.getSymbolSource(leftSymbol);
PlanNode right = context.getSymbolSource(rightSymbol);
edges.put(left.getId(), new Edge(right, leftSymbol, rightSymbol));
edges.put(right.getId(), new Edge(left, rightSymbol, leftSymbol));
}
return new JoinGraph(nodes, edges.build(), newRoot, joinedFilters, Optional.empty());
}
Aggregations