refactor(physical-plan): externalize statistics traversal into StatisticsContext#23051
Open
asolimando wants to merge 1 commit into
Open
refactor(physical-plan): externalize statistics traversal into StatisticsContext#23051asolimando wants to merge 1 commit into
asolimando wants to merge 1 commit into
Conversation
…ticsContext Decouple operator statistics propagation from tree traversal and caching, per apache#22958. - Add `StatisticsContext`, which owns the bottom-up walk and per-walk memoization cache. `compute(plan, args)` resolves each child before invoking the operator. - Add `ExecutionPlan::statistics_from_inputs(&self, input_stats, args)`: a stateless per-operator method that computes a node's statistics from pre-resolved child statistics. Default delegates to the deprecated `partition_statistics`. - Add `ExecutionPlan::child_stats_requests(&self, partition) -> Vec<ChildStats>` letting a node declare, per child, which partition to request (`ChildStats::At`) or to skip entirely (`ChildStats::Skip`). Union skips non-owning inputs on partition-specific requests. Operators no longer call back into the framework to fetch child statistics; caching is shared across a single walk via the context.
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
Member
Author
|
@2010YOUY01, @alamb: I have prepared this follow-up PR after #21815, it would be great if you could take a look at your convenience, I am in particular looking for guidance on the point raised in #22958 (comment). cc: @xudong963 in case you are interested in taking a look at this PR as well. Thank you folks for all the design and code feedback so far! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
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?
StatisticsContextowns the bottom-up walk + per-walk cache;compute(plan, args)resolves children, then calls the operator.
ExecutionPlan::statistics_from_inputs(input_stats, args)— stateless localpropagation from pre-resolved child stats; default delegates to deprecated
partition_statistics.ExecutionPlan::child_stats_requests(partition) -> Vec<ChildStats>— per-childdirective (
At(Option<usize>)/Skip) for which partition each child is computedat (e.g. broadcast joins request the build side overall;
UnionExecskipsnon-owning inputs).
statistics_with_args;partition_statisticsstaysdeprecated.
Are these changes tested?
Yes — existing statistics tests now run through
StatisticsContext::compute, plus newunit tests for the cache and the
compute_statisticsbenchmark.Are there any user-facing changes?
Yes (public
ExecutionPlanAPI):partition_statisticsdeprecated in favor ofstatistics_from_inputs; newStatisticsContext/ChildStats; unreleasedstatistics_with_argsremoved. Upgrade guide updated.Reviewer note:
statistics_from_inputstakesargs: &StatisticsArgs(currently justpartition) as a non-breaking extension seam rather than a barepartition— happyto 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.