private PlanWithProperties arbitraryDistributeUnion(
UnionNode node,
List<PlanWithProperties> plannedChildren,
List<PlanNode> partitionedChildren,
List<List<Symbol>> partitionedOutputLayouts)
{
if (countSources(partitionedChildren) == 0) {
return new PlanWithProperties(node.replaceChildren(
plannedChildren.stream()
.map(PlanWithProperties::getNode)
.collect(toList())));
}
else {
return new PlanWithProperties(
new ExchangeNode(
idAllocator.getNextId(),
REPARTITION,
REMOTE,
new PartitioningScheme(Partitioning.create(FIXED_ARBITRARY_DISTRIBUTION, ImmutableList.of()), node.getOutputSymbols()),
partitionedChildren,
partitionedOutputLayouts,
Optional.empty()));
}
}