@Override public PlanWithProperties visitExchange(ExchangeNode node, StreamPreferredProperties parentPreferences) { checkArgument(node.getScope() != LOCAL, "AddLocalExchanges can not process a plan containing a local exchange"); // this node changes the input organization completely, so we do not pass through parent preferences if (node.getOrderingScheme().isPresent()) { return planAndEnforceChildren( node, any().withOrderSensitivity(), any().withOrderSensitivity()); } return planAndEnforceChildren(node, any(), defaultParallelism(session)); }
return planAndEnforceChildren(node, singleStream(), defaultParallelism(session));
@Override public PlanWithProperties visitSort(SortNode node, StreamPreferredProperties parentPreferences) { if (isDistributedSortEnabled(session)) { PlanWithProperties sortPlan = planAndEnforceChildren(node, fixedParallelism(), fixedParallelism()); if (!sortPlan.getProperties().isSingleStream()) { return deriveProperties( mergingExchange( idAllocator.getNextId(), LOCAL, sortPlan.getNode(), node.getOrderingScheme()), sortPlan.getProperties()); } return sortPlan; } // sort requires that all data be in one stream // this node changes the input organization completely, so we do not pass through parent preferences return planAndEnforceChildren(node, singleStream(), defaultParallelism(session)); }
@Override public PlanWithProperties visitDistinctLimit(DistinctLimitNode node, StreamPreferredProperties parentPreferences) { // final limit requires that all data be in one stream StreamPreferredProperties requiredProperties; StreamPreferredProperties preferredProperties; if (node.isPartial()) { requiredProperties = parentPreferences.withoutPreference().withDefaultParallelism(session); preferredProperties = parentPreferences.withDefaultParallelism(session); } else { // a final changes the input organization completely, so we do not pass through parent preferences requiredProperties = singleStream(); preferredProperties = defaultParallelism(session); } return planAndEnforceChildren(node, requiredProperties, preferredProperties); }
@Override public PlanWithProperties visitLimit(LimitNode node, StreamPreferredProperties parentPreferences) { if (node.isPartial()) { return planAndEnforceChildren( node, parentPreferences.withoutPreference().withDefaultParallelism(session), parentPreferences.withDefaultParallelism(session)); } // final limit requires that all data be in one stream // also, a final changes the input organization completely, so we do not pass through parent preferences return planAndEnforceChildren( node, singleStream(), defaultParallelism(session)); }
@Override public PlanWithProperties visitTopN(TopNNode node, StreamPreferredProperties parentPreferences) { if (node.getStep().equals(TopNNode.Step.PARTIAL)) { return planAndEnforceChildren( node, parentPreferences.withoutPreference().withDefaultParallelism(session), parentPreferences.withDefaultParallelism(session)); } // final topN requires that all data be in one stream // also, a final changes the input organization completely, so we do not pass through parent preferences return planAndEnforceChildren( node, singleStream(), defaultParallelism(session)); }
@Override public PlanWithProperties visitTableWriter(TableWriterNode node, StreamPreferredProperties parentPreferences) { StreamPreferredProperties requiredProperties; StreamPreferredProperties preferredProperties; if (getTaskWriterCount(session) > 1) { requiredProperties = fixedParallelism(); preferredProperties = fixedParallelism(); } else { requiredProperties = singleStream(); preferredProperties = defaultParallelism(session); } return planAndEnforceChildren(node, requiredProperties, preferredProperties); }
@Override public PlanWithProperties visitTableFinish(TableFinishNode node, StreamPreferredProperties parentPreferences) { // table commit requires that all data be in one stream // this node changes the input organization completely, so we do not pass through parent preferences return planAndEnforceChildren(node, singleStream(), defaultParallelism(session)); }
@Override protected PlanWithProperties visitPlan(PlanNode node, StreamPreferredProperties parentPreferences) { return planAndEnforceChildren( node, parentPreferences.withoutPreference().withDefaultParallelism(session), parentPreferences.withDefaultParallelism(session)); }
@Override public PlanWithProperties visitRowNumber(RowNumberNode node, StreamPreferredProperties parentPreferences) { // row number requires that all data be partitioned StreamPreferredProperties requiredProperties = parentPreferences.withDefaultParallelism(session).withPartitioning(node.getPartitionBy()); return planAndEnforceChildren(node, requiredProperties, requiredProperties); }
@Override public PlanWithProperties visitEnforceSingleRow(EnforceSingleRowNode node, StreamPreferredProperties parentPreferences) { return planAndEnforceChildren(node, singleStream(), defaultParallelism(session)); }
@Override public PlanWithProperties visitOutput(OutputNode node, StreamPreferredProperties parentPreferences) { return planAndEnforceChildren( node, any().withOrderSensitivity(), any().withOrderSensitivity()); }
@Override public PlanWithProperties visitTopNRowNumber(TopNRowNumberNode node, StreamPreferredProperties parentPreferences) { StreamPreferredProperties requiredProperties = parentPreferences.withDefaultParallelism(session); // final topN row number requires that all data be partitioned if (!node.isPartial()) { requiredProperties = requiredProperties.withPartitioning(node.getPartitionBy()); } return planAndEnforceChildren(node, requiredProperties, requiredProperties); }
@Override public PlanWithProperties visitExplainAnalyze(ExplainAnalyzeNode node, StreamPreferredProperties parentPreferences) { // Although explain analyze discards all output, we want to maintain the behavior // of a normal output node, so declare the node to be order sensitive return planAndEnforceChildren( node, singleStream().withOrderSensitivity(), singleStream().withOrderSensitivity()); }