@@ -96,3 +96,68 @@ as a supertrait:
9696- pub trait QueryPlanner: Debug
9797+ pub trait QueryPlanner: Any + Debug
9898```
99+
100+ ### ` ExecutionPlan::partition_statistics ` deprecated in favor of ` statistics_with_args `
101+
102+ ` ExecutionPlan::partition_statistics ` is deprecated. A new method
103+ ` statistics_with_args ` accepts a ` StatisticsArgs ` parameter that bundles
104+ the partition index and a ` StatisticsContext ` carrying pre-computed child
105+ statistics and additional context for statistics computation.
106+
107+ Existing implementations of ` partition_statistics ` continue to work unchanged.
108+ The default ` statistics_with_args ` delegates to the deprecated method, so no
109+ migration is required until the deprecated method is removed.
110+
111+ ** Who is affected:**
112+
113+ - Users who implement custom ` ExecutionPlan ` nodes (recommended to migrate)
114+ - Users who call ` partition_statistics ` directly (recommended to switch to ` compute_statistics ` )
115+
116+ ** Migration guide:**
117+
118+ For ** implementations** , override ` statistics_with_args ` instead of
119+ ` partition_statistics ` . Leaf nodes that do not have children can ignore the
120+ context.
121+
122+ Child statistics are looked up via ` args.compute_child_statistics(child, partition) ` .
123+ Use ` args.partition() ` for partition-preserving operators, or ` None ` for
124+ partition-merging operators that always need overall stats:
125+
126+ ``` rust,ignore
127+ // Before:
128+ fn partition_statistics(&self, partition: Option<usize>) -> Result<Arc<Statistics>> {
129+ let child_stats = self.input.partition_statistics(partition)?;
130+ // ... transform child_stats ...
131+ }
132+
133+ // After (partition-preserving):
134+ fn statistics_with_args(
135+ &self,
136+ args: &StatisticsArgs,
137+ ) -> Result<Arc<Statistics>> {
138+ let child_stats = args.compute_child_statistics(self.input.as_ref(), args.partition())?;
139+ // ... transform child_stats ...
140+ }
141+
142+ // After (partition-merging):
143+ fn statistics_with_args(
144+ &self,
145+ args: &StatisticsArgs,
146+ ) -> Result<Arc<Statistics>> {
147+ let child_stats = args.compute_child_statistics(self.input.as_ref(), None)?;
148+ // ... transform child_stats ...
149+ }
150+ ```
151+
152+ For ** callers** , replace direct calls with ` compute_statistics ` , which walks
153+ the plan tree bottom-up and threads child statistics through the context
154+ automatically:
155+
156+ ``` rust,ignore
157+ use datafusion_physical_plan::compute_statistics;
158+
159+ // Before:
160+ let stats = plan.partition_statistics(None)?;
161+
162+ // After:
163+ let stats = compute_statistics(plan.as_ref(), None)?;
0 commit comments