@Override public List<Symbol> getOutputSymbols() { return source.getOutputSymbols(); }
@Override public List<Symbol> getOutputSymbols() { return ImmutableList.<Symbol>builder() .addAll(source.getOutputSymbols()) .add(idColumn) .build(); }
private static ImmutableSet<Symbol> createInputs(PlanNode source, Set<Symbol> boundSymbols) { return ImmutableSet.<Symbol>builder() .addAll(source.getOutputSymbols()) .addAll(boundSymbols) .build(); } }
private boolean isUnreferencedScalar(PlanNode planNode, Lookup lookup) { return planNode.getOutputSymbols().isEmpty() && isScalar(planNode, lookup); } }
public MultiJoinNode(LinkedHashSet<PlanNode> sources, Expression filter, List<Symbol> outputSymbols) { requireNonNull(sources, "sources is null"); checkArgument(sources.size() > 1, "sources size is <= 1"); requireNonNull(filter, "filter is null"); requireNonNull(outputSymbols, "outputSymbols is null"); this.sources = sources; this.filter = filter; this.outputSymbols = ImmutableList.copyOf(outputSymbols); List<Symbol> inputSymbols = sources.stream().flatMap(source -> source.getOutputSymbols().stream()).collect(toImmutableList()); checkArgument(inputSymbols.containsAll(outputSymbols), "inputs do not contain all output symbols"); }
public static ExchangeNode replicatedExchange(PlanNodeId id, Scope scope, PlanNode child) { return new ExchangeNode( id, ExchangeNode.Type.REPLICATE, scope, new PartitioningScheme(Partitioning.create(FIXED_BROADCAST_DISTRIBUTION, ImmutableList.of()), child.getOutputSymbols()), ImmutableList.of(child), ImmutableList.of(child.getOutputSymbols()), Optional.empty()); }
public static ExchangeNode gatheringExchange(PlanNodeId id, Scope scope, PlanNode child) { return new ExchangeNode( id, ExchangeNode.Type.GATHER, scope, new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), child.getOutputSymbols()), ImmutableList.of(child), ImmutableList.of(child.getOutputSymbols()), Optional.empty()); }
@Override public Map<Symbol, Symbol> visitIndexJoin(IndexJoinNode node, Set<Symbol> lookupSymbols) { Set<Symbol> probeLookupSymbols = lookupSymbols.stream() .filter(node.getProbeSource().getOutputSymbols()::contains) .collect(toImmutableSet()); checkState(!probeLookupSymbols.isEmpty(), "No lookup symbols were able to pass through the index join probe source"); return node.getProbeSource().accept(this, probeLookupSymbols); }
@Override public Void visitOutput(OutputNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); // visit child checkDependencies(source.getOutputSymbols(), node.getOutputSymbols(), "Invalid node. Output column dependencies (%s) not in source plan output (%s)", node.getOutputSymbols(), source.getOutputSymbols()); return null; }
@Override public boolean shapeMatches(PlanNode node) { return (node instanceof ValuesNode) && expectedOutputSymbolCount.map(Integer.valueOf(node.getOutputSymbols().size())::equals).orElse(true); }
private PlanWithProperties plan(PlanNode node, HashComputationSet parentPreference) { PlanWithProperties result = node.accept(this, parentPreference); checkState( result.getNode().getOutputSymbols().containsAll(result.getHashSymbols().values()), "Node %s declares hash symbols not in the output", result.getNode().getClass().getSimpleName()); return result; } }
public static ExchangeNode roundRobinExchange(PlanNodeId id, Scope scope, PlanNode child) { return partitionedExchange( id, scope, child, new PartitioningScheme(Partitioning.create(FIXED_ARBITRARY_DISTRIBUTION, ImmutableList.of()), child.getOutputSymbols())); }
@Override public Void visitRowNumber(RowNumberNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); // visit child checkDependencies(source.getOutputSymbols(), node.getPartitionBy(), "Invalid node. Partition by symbols (%s) not in source plan output (%s)", node.getPartitionBy(), node.getSource().getOutputSymbols()); return null; }
@Override public Result apply(ProjectNode parent, Captures captures, Context context) { N targetNode = captures.get(targetCapture); return pruneInputs(targetNode.getOutputSymbols(), parent.getAssignments().getExpressions()) .flatMap(prunedOutputs -> this.pushDownProjectOff(context.getIdAllocator(), targetNode, prunedOutputs)) .map(newChild -> parent.replaceChildren(ImmutableList.of(newChild))) .map(Result::ofPlanNode) .orElse(Result.empty()); }
private PlanNode pushPartialToRightChild(AggregationNode node, JoinNode child, Context context) { Set<Symbol> joinRightChildSymbols = ImmutableSet.copyOf(child.getRight().getOutputSymbols()); List<Symbol> groupingSet = getPushedDownGroupingSet(node, joinRightChildSymbols, intersection(getJoinRequiredSymbols(child), joinRightChildSymbols)); AggregationNode pushedAggregation = replaceAggregationSource(node, child.getRight(), groupingSet); return pushPartialToJoin(node, child, child.getLeft(), pushedAggregation, context); }
private String formatPlanNodeStatsAndCost(PlanNode node) { PlanNodeStatsEstimate stats = estimatedStatsAndCosts.getStats().getOrDefault(node.getId(), PlanNodeStatsEstimate.unknown()); PlanNodeCostEstimate cost = estimatedStatsAndCosts.getCosts().getOrDefault(node.getId(), PlanNodeCostEstimate.unknown()); return format("{rows: %s (%s), cpu: %s, memory: %s, network: %s}", formatAsLong(stats.getOutputRowCount()), formatEstimateAsDataSize(stats.getOutputSizeInBytes(node.getOutputSymbols(), types)), formatDouble(cost.getCpuCost()), formatDouble(cost.getMemoryCost()), formatDouble(cost.getNetworkCost())); } }
private ProjectNode projectExpressions(PlanNode input, Assignments subqueryAssignments) { Assignments assignments = Assignments.builder() .putIdentities(input.getOutputSymbols()) .putAll(subqueryAssignments) .build(); return new ProjectNode( idAllocator.getNextId(), input, assignments); } }
@Override public PlanNode visitTableFinish(TableFinishNode node, RewriteContext<Set<Symbol>> context) { PlanNode source = context.rewrite(node.getSource(), ImmutableSet.copyOf(node.getSource().getOutputSymbols())); return new TableFinishNode( node.getId(), source, node.getTarget(), node.getRowCountSymbol(), node.getStatisticsAggregation(), node.getStatisticsAggregationDescriptor()); }
private static PlanNode addProjection(Context context, PlanNode node, Symbol symbol, Expression expression) { Assignments.Builder projections = Assignments.builder(); for (Symbol outputSymbol : node.getOutputSymbols()) { projections.putIdentity(outputSymbol); } projections.put(symbol, expression); return new ProjectNode(context.getIdAllocator().getNextId(), node, projections.build()); }
@Override public PlanWithProperties visitSemiJoin(SemiJoinNode node, StreamPreferredProperties parentPreferences) { PlanWithProperties source = planAndEnforce( node.getSource(), defaultParallelism(session), parentPreferences.constrainTo(node.getSource().getOutputSymbols()).withDefaultParallelism(session)); // this filter source consumes the input completely, so we do not pass through parent preferences PlanWithProperties filteringSource = planAndEnforce(node.getFilteringSource(), singleStream(), singleStream()); return rebaseAndDeriveProperties(node, ImmutableList.of(source, filteringSource)); }