Support multiple sources for all remote exchanges
Add support for REPARTITION and REPLICATE
@@ -37,7 +37,6 @@ import com.facebook.presto.sql.planner.plan.ValuesNode;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import java.util.ArrayList;
@@ -186,24 +185,17 @@ public class PlanFragmenter
PartitioningScheme partitioningScheme = exchange.getPartitioningScheme();
- ImmutableList.Builder<SubPlan> builder = ImmutableList.builder();
if (exchange.getType() == ExchangeNode.Type.GATHER) {
context.get().setSingleNodeDistribution();
-
- for (int i = 0; i < exchange.getSources().size(); i++) {
- FragmentProperties childProperties = new FragmentProperties(partitioningScheme.translateOutputLayout(exchange.getInputs().get(i)));
- builder.add(buildSubPlan(exchange.getSources().get(i), childProperties, context));
- }
}
else if (exchange.getType() == ExchangeNode.Type.REPARTITION) {
context.get().setDistribution(partitioningScheme.getPartitioning().getHandle());
-
- FragmentProperties childProperties = new FragmentProperties(partitioningScheme.translateOutputLayout(Iterables.getOnlyElement(exchange.getInputs())));
- builder.add(buildSubPlan(Iterables.getOnlyElement(exchange.getSources()), childProperties, context));
}
- else if (exchange.getType() == ExchangeNode.Type.REPLICATE) {
- FragmentProperties childProperties = new FragmentProperties(partitioningScheme.translateOutputLayout(Iterables.getOnlyElement(exchange.getInputs())));
- builder.add(buildSubPlan(Iterables.getOnlyElement(exchange.getSources()), childProperties, context));
+
+ ImmutableList.Builder<SubPlan> builder = ImmutableList.builder();
+ for (int sourceIndex = 0; sourceIndex < exchange.getSources().size(); sourceIndex++) {
+ FragmentProperties childProperties = new FragmentProperties(partitioningScheme.translateOutputLayout(exchange.getInputs().get(sourceIndex)));
+ builder.add(buildSubPlan(exchange.getSources().get(sourceIndex), childProperties, context));
}
List<SubPlan> children = builder.build();
