Repository navigation
Conversation
Records the current behavior: predicates on `get_field(s, 'a')` get no pruning predicate, so every row group is read. Later commits update the expected output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`RequiredColumns` and `PruningExpressionBuilder` identify the statistics they read by a bare column. Struct field pruning needs to read statistics for `get_field(s, 'a')`, which is not a column. This adds a field path next to each required column (empty for the column itself) and a `StatsKey` that `ColumnReferenceCount` returns. Every path is still empty, so behavior does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`PruningStatistics` only returns statistics for a whole column. Add `min_values_for_field`, `max_values_for_field` and `null_counts_for_field`, which take a column and a struct field path. The defaults return `None`, so existing implementations keep working and prune nothing for struct fields. `CompositePruningStatistics` forwards the new methods to its members. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`PruningPredicate` gives up on `get_field(s, 'a') > 5` because the left side is not a column. Recognize `get_field(column, 'a', ...)`, including chained calls, as one statistics key and replace the whole access with its statistics column. The pruning crate does not depend on `datafusion-functions`, so it matches the function by its name. The key is only accepted when every step is a struct field and the leaf is not nested: `get_field` on a map is a runtime lookup, and a field below a list has per-element statistics. `RequiredColumns::single_column` returns `None` for a field path so that the page index does not read the root column. No statistics source implements the new methods yet, so the plans gain a pruning predicate but nothing is pruned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement the struct field methods of `PruningStatistics` for `RowGroupPruningStatistics`. The field path resolves to the Parquet leaf column, and its statistics go through the same untrusted-statistics checks as a top-level column. A path is rejected when a step is not a struct field, when the leaf is nested, or when an ancestor is repeated. For a struct-only path, the leaf null count includes rows where an ancestor struct is null. That matches `get_field`, which returns null in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover the cases that the slt cannot show directly: which expressions are rejected (two fields, a field plus a column, a map lookup), and that a field path is never reported as the single column of a predicate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page index needs the same field path to Parquet leaf lookup as row group pruning. Move it into `struct_field_leaf` so both use one implementation. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Records the current behavior: the page index is not used for `s['a'] >= 85`, so all 10 pages of the row group are read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page index only accepts predicates whose statistics come from one column, through `RequiredColumns::single_column`. That excludes struct field paths, so `s['a'] >= 85` read every page of a row group. Add `RequiredColumns::single_field`, which also accepts one struct field path. The page filter resolves the path to its Parquet leaf with `struct_field_leaf`, and `PagesPruningStatistics` answers the struct field methods from that leaf's converter. The page index load check uses the same leaf lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriangb
commented
Nov 25, 2026
| /// [`Self::min_values`]. | ||
| /// | ||
| /// The default returns `None`, so pruning keeps every container. | ||
| fn min_values_for_field( |
Contributor
Author
There was a problem hiding this comment.
Open question: should this take an expression instead of a column + path?
An expression would also cover lower(col) backed by a precomputed column, or variant_get. A path only covers struct fields.
I used a path because PruningStatistics lives in datafusion-common, which cannot name PhysicalExpr (physical-expr-common depends on common). An expression-keyed API means moving this trait (and PrunableStatistics / CompositePruningStatistics) to physical-expr-common, with a re-export here.
A path can be widened later: expression methods with a default that maps get_field(col, ...) to these path methods. Should we move the trait now instead?
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
SELECT * FROM t WHERE s['a'] > 5reads every Parquet row group.PruningPredicateonly understands predicates on top-level columns, andPruningStatisticshas no way to ask for the statistics of a struct field.What changes are included in this PR?
A field path is only accepted when every step is a struct field and the leaf is not nested. Map lookups and paths below a list (per-element statistics) are rejected.
datafusion-pruningdoes not depend ondatafusion-functions, so it matchesget_fieldby name. A function-agnostic accessor trait would letvariant_getopt in later (#21306).Review commit by commit:
test:addsparquet_struct_field_pruning.sltwith today's output (no pruning).refactor:keysRequiredColumns/PruningExpressionBuilderby column + path. No behavior change.feat:adds the*_for_fieldmethods toPruningStatistics, withNonedefaults.feat:recognizesget_fieldinPruningPredicate. Plans gain apruning_predicate, but nothing is pruned yet.feat:implements the methods for Parquet row groups. The slt diff shows the pruning.test:unit tests for rejected shapes andsingle_column().refactor:moves the field-to-leaf lookup intoleaf_resolver::struct_field_leaf. No behavior change.test:adds a page-index slt case with today's output.feat:page index pruning for struct fields.Not included: file-level pruning, which needs nested
Statistics(#20707).What is the testing strategy for this PR?
parquet_struct_field_pruning.sltcovers 4 row groups, including a null struct and a null leaf, plus 2 files:s['a'] > 15s['a'] <= 2,11 = s['a'],s['a'] = 20s['a'] > 25 OR id < 2s['a'] > s['b']s['a'] < 10s['a'] >= 85(page index)Unit tests in
pruning_predicate.rscover the rejected shapes andsingle_column().Are there any user-facing changes?
Fewer row groups are read for struct field predicates.
EXPLAINshows apruning_predicatesuch ass.a_null_count@1 != row_count@2 AND s.a_max@0 > 15.API: three new provided methods on
PruningStatistics. Existing implementations keep compiling.RequiredColumns::single_column()now returnsNonefor predicates that touch a struct field.Door: two-way. Revert restores the old plans.
Blast radius: pruning. A wrong field-to-leaf mapping or wrong null count would prune row groups that hold matching rows (wrong results). The checks above and the null-struct / null-leaf slt cases target that.
🤖 Generated with Claude Code