Per-conjunct pruning statistics for PruningPredicate#22235
Conversation
Introduce `OptionalFilterPhysicalExpr`, a transparent `PhysicalExpr` wrapper that marks a filter as *optional* — droppable without affecting query correctness. It delegates every `PhysicalExpr` method to the inner expression, so it is behavior-neutral until a consumer explicitly checks for the marker. This is the foundation for adaptive filter scheduling: a scan can detect the wrapper and drop a performance-hint filter (e.g. a hash-join dynamic filter) when it is not cost-effective, knowing correctness is enforced elsewhere. Also adds proto serialization (`PhysicalOptionalFilterNode`) so physical plans containing the wrapper round-trip faithfully. No caller wraps anything yet — that arrives with the adaptive parquet scan later in the stack. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add an opt-in way to learn, per individual conjunct, how effective each predicate was during pruning — without running any extra pruning passes. - `PruningPredicate::try_new_tagged_conjuncts` builds a predicate from AND-conjuncts, each carrying a caller-supplied tag. - `PruningPredicate::prune_per_conjunct` returns the usual prune mask plus per-conjunct `PerConjunctPruneStats` (rows/containers seen vs. skipped) as a side effect of the pruning iteration that already runs. - `RowGroupAccessPlanFilter::prune_by_statistics_with_per_conjunct_stats` and `PagePruningAccessPlanFilter::prune_plan_with_per_conjunct_stats` surface those stats for row-group and page-index pruning respectively. The existing untagged `prune` / `prune_by_statistics` / `prune_plan_with_page_index` paths are preserved and unchanged; the new methods return empty stats on the untagged path. No in-tree caller uses the tagged path yet — the adaptive parquet scan consumes it later in the stack as a selectivity prior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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 |
|
This would also be extremely useful for bootstrapping a cold stats in catalog via execution and runtime stats, I hope this feature lands! |
|
If you're willing to help review / get this in good shape for a review from a committer I think that would go a long way towards getting it across the line. I've mostly gotten it to work without paying too much attention to the API, interaction with existing methods, etc., hence why this is in draft. |
Sure, I will put it on my to-do list for next week when I am back from holidays! |
Which issue does this PR close?
Rationale for this change
Adaptive filter scheduling needs to know how effective each individual predicate conjunct was, so it can decide where to place that conjunct. Today pruning only reports an aggregate result. This PR surfaces per-conjunct effectiveness as a free side effect of the pruning pass that already runs — no extra passes.
What changes are included in this PR?
PruningPredicate::try_new_tagged_conjuncts— build a predicate from AND-conjuncts, each carrying a caller-supplied tag.PruningPredicate::prune_per_conjunct— returns the usual prune mask plus per-conjunctPerConjunctPruneStats.RowGroupAccessPlanFilter::prune_by_statistics_with_per_conjunct_statsandPagePruningAccessPlanFilter::prune_plan_with_per_conjunct_stats— surface those stats for row-group and page-index pruning.Existing untagged
prune/prune_by_statistics/prune_plan_with_page_indexpaths are preserved and unchanged. No in-tree caller uses the tagged path yet.Are these changes tested?
Yes — unit tests for the tagged-conjunct constructor and per-conjunct stat accounting.
Are there any user-facing changes?
New public API on
PruningPredicate. Purely additive; no behavior change.Stacked PR — diff is cumulative against
main. Review the top commit "feat: per-conjunct pruning statistics for PruningPredicate"; the commit below it is PR #22234.Stack (review/merge in order):