Add support for AssignUniqueId partitioning in PropertyDerivations
@@ -85,6 +85,7 @@ import java.util.stream.Collectors;
import static com.facebook.presto.SystemSessionProperties.planWithTableNodePartitioning;
import static com.facebook.presto.spi.predicate.TupleDomain.extractFixedValues;
import static com.facebook.presto.sql.analyzer.ExpressionAnalyzer.getExpressionTypes;
+import static com.facebook.presto.sql.planner.SystemPartitioningHandle.ARBITRARY_DISTRIBUTION;
import static com.facebook.presto.sql.planner.optimizations.ActualProperties.Global.arbitraryPartition;
import static com.facebook.presto.sql.planner.optimizations.ActualProperties.Global.coordinatorSingleStreamPartition;
import static com.facebook.presto.sql.planner.optimizations.ActualProperties.Global.partitionedOn;
@@ -181,7 +182,15 @@ public class PropertyDerivations
@Override
public ActualProperties visitAssignUniqueId(AssignUniqueId node, List<ActualProperties> inputProperties)
{
- return Iterables.getOnlyElement(inputProperties);
+ ActualProperties properties = Iterables.getOnlyElement(inputProperties);
+ if (properties.getNodePartitioning().isPresent()) {
+ // preserve input (possibly preferred) partitioning
+ return properties;
+ }
+
+ return ActualProperties.builderFrom(properties)
+ .global(partitionedOn(ARBITRARY_DISTRIBUTION, ImmutableList.of(node.getIdColumn()), Optional.empty()))
+ .build();
}
@Override
