You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(physical-plan): externalize statistics traversal into StatisticsContext (#23051)
## Which issue does this PR close?
- Closes#22958.
## Rationale for this change
Follow-up to #21815. Per @2010YOUY01's suggestion there, this decouples
statistics
traversal/caching from each operator's computation: operators now
express only local
propagation, while the walk and cache live in an external
`StatisticsContext`.
## What changes are included in this PR?
- `StatisticsContext` owns the bottom-up walk + per-walk cache;
`compute(plan, args)`
resolves children, then calls the operator.
- `ExecutionPlan::statistics_from_inputs(input_stats, args)` — stateless
local
propagation from pre-resolved child stats; default delegates to
deprecated
`partition_statistics`.
- `ExecutionPlan::child_stats_requests(partition) -> Vec<ChildStats>` —
per-child
directive (`At(Option<usize>)` / `Skip`) for which partition each child
is computed
at (e.g. broadcast joins request the build side overall; `UnionExec`
skips
non-owning inputs).
- Removes the unreleased `statistics_with_args`; `partition_statistics`
stays
deprecated.
- Migrates all operators/callers; updates the 55.0.0 upgrade guide.
## Are these changes tested?
Yes — existing statistics tests now run through
`StatisticsContext::compute`, plus new
unit tests for the cache and the `compute_statistics` benchmark.
## Are there any user-facing changes?
Yes (public `ExecutionPlan` API): `partition_statistics` deprecated in
favor of
`statistics_from_inputs`; new `StatisticsContext` / `ChildStats`;
unreleased
`statistics_with_args` removed. Upgrade guide updated.
---
Reviewer note: `statistics_from_inputs` takes `args: &StatisticsArgs`
(currently just
`partition`) as a non-breaking extension seam rather than a bare
`partition` — happy
to change if preferred (see #22958).
----
Disclaimer: I used AI to assist in the code generation, I have manually
reviewed the output and it matches my intention and understanding.
---------
Co-authored-by: xudong.w <wxd963996380@gmail.com>
0 commit comments