From 8ca56a24369d3917bc9599716ec4c58cff344a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Heres?= Date: Mon, 9 Dec 2024 16:31:22 +0100 Subject: [PATCH] Always add round robin repartition for child sources --- .../core/src/physical_optimizer/enforce_distribution.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datafusion/core/src/physical_optimizer/enforce_distribution.rs b/datafusion/core/src/physical_optimizer/enforce_distribution.rs index 27323eaedccc..570791af5950 100644 --- a/datafusion/core/src/physical_optimizer/enforce_distribution.rs +++ b/datafusion/core/src/physical_optimizer/enforce_distribution.rs @@ -836,7 +836,9 @@ fn add_roundrobin_on_top( n_target: usize, ) -> Result { // Adding repartition is helpful: - if input.plan.output_partitioning().partition_count() < n_target { + if input.plan.output_partitioning().partition_count() < n_target + || input.plan.children().is_empty() + { // When there is an existing ordering, we preserve ordering // during repartition. This will be un-done in the future // If any of the following conditions is true