This is an automated email from the ASF dual-hosted git repository. alamb pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push: new 10f41887fa chore: replace deprecated UnionExec API (#17588) 10f41887fa is described below commit 10f41887fa40d7d425c19b07857f80115460a98e Author: Eugene Tolbakov <ev.tolba...@gmail.com> AuthorDate: Tue Sep 16 13:25:38 2025 +0100 chore: replace deprecated UnionExec API (#17588) --- .../tests/physical_optimizer/enforce_distribution.rs | 6 ++---- .../tests/physical_optimizer/partition_statistics.rs | 3 +-- .../tests/physical_optimizer/projection_pushdown.rs | 3 +-- datafusion/core/tests/physical_optimizer/test_utils.rs | 3 +-- datafusion/physical-plan/src/repartition/mod.rs | 18 ++++++------------ datafusion/physical-plan/src/union.rs | 9 +++------ datafusion/proto/src/physical_plan/mod.rs | 3 +-- .../proto/tests/cases/roundtrip_physical_plan.rs | 5 ++--- 8 files changed, 17 insertions(+), 33 deletions(-) diff --git a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs index 1ddeb3c611..63111f4380 100644 --- a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs +++ b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs @@ -1783,8 +1783,7 @@ fn union_to_interleave() -> Result<()> { ); // Union - #[allow(deprecated)] - let plan = Arc::new(UnionExec::new(vec![left, right])); + let plan = UnionExec::try_new(vec![left, right])?; // final agg let plan = @@ -1828,8 +1827,7 @@ fn union_not_to_interleave() -> Result<()> { ); // Union - #[allow(deprecated)] - let plan = Arc::new(UnionExec::new(vec![left, right])); + let plan = UnionExec::try_new(vec![left, right])?; // final agg let plan = diff --git a/datafusion/core/tests/physical_optimizer/partition_statistics.rs b/datafusion/core/tests/physical_optimizer/partition_statistics.rs index 26f179a6cd..a7b06bc7be 100644 --- a/datafusion/core/tests/physical_optimizer/partition_statistics.rs +++ b/datafusion/core/tests/physical_optimizer/partition_statistics.rs @@ -356,9 +356,8 @@ mod test { #[tokio::test] async fn test_statistic_by_partition_of_union() -> Result<()> { let scan = create_scan_exec_with_statistics(None, Some(2)).await; - #[allow(deprecated)] let union_exec: Arc<dyn ExecutionPlan> = - Arc::new(UnionExec::new(vec![scan.clone(), scan])); + UnionExec::try_new(vec![scan.clone(), scan])?; let statistics = (0..union_exec.output_partitioning().partition_count()) .map(|idx| union_exec.partition_statistics(Some(idx))) .collect::<Result<Vec<_>>>()?; diff --git a/datafusion/core/tests/physical_optimizer/projection_pushdown.rs b/datafusion/core/tests/physical_optimizer/projection_pushdown.rs index ab753d00b4..0a75d9f52e 100644 --- a/datafusion/core/tests/physical_optimizer/projection_pushdown.rs +++ b/datafusion/core/tests/physical_optimizer/projection_pushdown.rs @@ -1535,8 +1535,7 @@ fn test_sort_preserving_after_projection() -> Result<()> { #[test] fn test_union_after_projection() -> Result<()> { let csv = create_simple_csv_exec(); - #[allow(deprecated)] - let union = Arc::new(UnionExec::new(vec![csv.clone(), csv.clone(), csv])); + let union = UnionExec::try_new(vec![csv.clone(), csv.clone(), csv])?; let projection: Arc<dyn ExecutionPlan> = Arc::new(ProjectionExec::try_new( vec![ ProjectionExpr::new(Arc::new(Column::new("c", 2)), "c".to_string()), diff --git a/datafusion/core/tests/physical_optimizer/test_utils.rs b/datafusion/core/tests/physical_optimizer/test_utils.rs index 49efe24fb8..7c9fb9de53 100644 --- a/datafusion/core/tests/physical_optimizer/test_utils.rs +++ b/datafusion/core/tests/physical_optimizer/test_utils.rs @@ -304,8 +304,7 @@ pub fn sort_preserving_merge_exec_with_fetch( } pub fn union_exec(input: Vec<Arc<dyn ExecutionPlan>>) -> Arc<dyn ExecutionPlan> { - #[allow(deprecated)] - Arc::new(UnionExec::new(input)) + UnionExec::try_new(input).unwrap() } pub fn local_limit_exec( diff --git a/datafusion/physical-plan/src/repartition/mod.rs b/datafusion/physical-plan/src/repartition/mod.rs index cd188a648f..22bc1b5cf9 100644 --- a/datafusion/physical-plan/src/repartition/mod.rs +++ b/datafusion/physical-plan/src/repartition/mod.rs @@ -1783,12 +1783,9 @@ mod test { let source1 = sorted_memory_exec(&schema, sort_exprs.clone()); let source2 = sorted_memory_exec(&schema, sort_exprs); // output has multiple partitions, and is sorted - #[allow(deprecated)] - let union = UnionExec::new(vec![source1, source2]); - let exec = - RepartitionExec::try_new(Arc::new(union), Partitioning::RoundRobinBatch(10)) - .unwrap() - .with_preserve_order(); + let union = UnionExec::try_new(vec![source1, source2])?; + let exec = RepartitionExec::try_new(union, Partitioning::RoundRobinBatch(10))? + .with_preserve_order(); // Repartition should preserve order let expected_plan = [ @@ -1826,12 +1823,9 @@ mod test { let source1 = memory_exec(&schema); let source2 = memory_exec(&schema); // output has multiple partitions, but is not sorted - #[allow(deprecated)] - let union = UnionExec::new(vec![source1, source2]); - let exec = - RepartitionExec::try_new(Arc::new(union), Partitioning::RoundRobinBatch(10)) - .unwrap() - .with_preserve_order(); + let union = UnionExec::try_new(vec![source1, source2])?; + let exec = RepartitionExec::try_new(union, Partitioning::RoundRobinBatch(10))? + .with_preserve_order(); // Repartition should not preserve order, as there is no order to preserve let expected_plan = [ diff --git a/datafusion/physical-plan/src/union.rs b/datafusion/physical-plan/src/union.rs index f1e9ee53ac..b4591f46f0 100644 --- a/datafusion/physical-plan/src/union.rs +++ b/datafusion/physical-plan/src/union.rs @@ -352,8 +352,7 @@ impl ExecutionPlan for UnionExec { .map(|child| make_with_child(projection, child)) .collect::<Result<Vec<_>>>()?; - #[allow(deprecated)] - Ok(Some(Arc::new(UnionExec::new(new_children)))) + Ok(Some(UnionExec::try_new(new_children.clone())?)) } } @@ -751,8 +750,7 @@ mod tests { let csv = test::scan_partitioned(4); let csv2 = test::scan_partitioned(5); - #[allow(deprecated)] - let union_exec = Arc::new(UnionExec::new(vec![csv, csv2])); + let union_exec: Arc<dyn ExecutionPlan> = UnionExec::try_new(vec![csv, csv2])?; // Should have 9 partitions and 9 output batches assert_eq!( @@ -934,8 +932,7 @@ mod tests { let mut union_expected_eq = EquivalenceProperties::new(Arc::clone(&schema)); union_expected_eq.add_orderings(union_expected_orderings); - #[allow(deprecated)] - let union = UnionExec::new(vec![child1, child2]); + let union: Arc<dyn ExecutionPlan> = UnionExec::try_new(vec![child1, child2])?; let union_eq_properties = union.properties().equivalence_properties(); let err_msg = format!( "Error in test id: {:?}, test case: {:?}", diff --git a/datafusion/proto/src/physical_plan/mod.rs b/datafusion/proto/src/physical_plan/mod.rs index 0d6bdeb08b..04a4372c19 100644 --- a/datafusion/proto/src/physical_plan/mod.rs +++ b/datafusion/proto/src/physical_plan/mod.rs @@ -1405,8 +1405,7 @@ impl protobuf::PhysicalPlanNode { for input in &union.inputs { inputs.push(input.try_into_physical_plan(ctx, runtime, extension_codec)?); } - #[allow(deprecated)] - Ok(Arc::new(UnionExec::new(inputs))) + UnionExec::try_new(inputs) } fn try_into_interleave_physical_plan( diff --git a/datafusion/proto/tests/cases/roundtrip_physical_plan.rs b/datafusion/proto/tests/cases/roundtrip_physical_plan.rs index f408ec1a91..4b4403a5f3 100644 --- a/datafusion/proto/tests/cases/roundtrip_physical_plan.rs +++ b/datafusion/proto/tests/cases/roundtrip_physical_plan.rs @@ -1649,9 +1649,8 @@ fn roundtrip_union() -> Result<()> { let left = EmptyExec::new(Arc::new(schema_left)); let right = EmptyExec::new(Arc::new(schema_right)); let inputs: Vec<Arc<dyn ExecutionPlan>> = vec![Arc::new(left), Arc::new(right)]; - #[allow(deprecated)] - let union = UnionExec::new(inputs); - roundtrip_test(Arc::new(union)) + let union = UnionExec::try_new(inputs)?; + roundtrip_test(union) } #[test] --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org For additional commands, e-mail: commits-h...@datafusion.apache.org