Repository navigation
Conversation
`PruningStatistics` lives in `datafusion-common`, which cannot name `PhysicalExpr`. Asking a statistics source for the statistics of an expression (such as `get_field(s, 'a')` or `variant_get(v, 'a')`) needs the trait to live next to `PhysicalExpr`. This is a mechanical move of `datafusion_common::pruning` to `datafusion_physical_expr_common::pruning` and an update of the imports. `datafusion_common` cannot re-export it, because `physical-expr-common` depends on it, so the old path is removed. `datafusion_pruning::PruningStatistics` keeps working. The 57.0.0 upgrade guide describes the new import path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`build_predicate_expression` takes the schema, the unhandled-predicate hook and the IN-list limit as separate arguments and passes all three to each recursive call. Struct field pruning adds one more read-only setting (which expressions have their own statistics). Bundle them in `PredicateBuildContext`. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`PruningStatistics` can only answer for a column, but a data source can also know the statistics of an expression, such as `get_field(s, 'a')`. `StatsExpr` holds an expression and the binding that the source made for it. The new `*_for_expr` methods take a `StatsExpr` and return `None` by default, so existing implementations keep compiling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`RequiredColumns` and `PruningExpressionBuilder` identify the statistics they read by a bare column. Pruning on `get_field(s, 'a')` or `variant_get(v, 'a')` needs statistics for an expression that is not a column. Add an optional expression next to each required column, and a `StatsKey` that `ColumnReferenceCount` returns. Every helper that reads statistics takes a `StatsKey`, and `RequiredColumns::stat_key_expr` replaces the per-statistic `*_column_expr` wrappers. The statistics record batch reads expression statistics through `*_for_expr`. Every key is still a plain column, so behavior does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A source can now pass a `StatisticsExprMatcher` to the predicate builder. The rewrite asks the matcher to bind each expression, outermost first. A bound expression becomes a statistics key, like a column. An unbound expression falls back to the keys inside it. The key carries the binding, so the source never looks the expression up again. Looking it up by value would hash the whole subtree at every node, which is quadratic for a deep predicate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parquet stores statistics for each struct field, but a predicate on a struct field such as `s['a'] > 15` cannot prune row groups or pages yet. Add `parquet_struct_field_pruning.slt` with the current output, so the next commits show what changes. It covers row groups, two files, the page index, a dynamic TopK filter, struct type drift, a long `IN` list, a hash join dynamic filter, and a struct field that is NULL in a non-nullable struct. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parquet stores statistics for every struct field leaf, but a predicate on `s['a']` could not use them. `StructFieldMatcher` binds `get_field` to its Parquet leaf, once per file. Row group pruning, full match detection, dynamic filter pruning and EXPLAIN use it. A missing null count stays unknown, because reading it as zero prunes rows that `IS NULL` must return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page index of a struct field leaf prunes pages the same way as the page index of a column. A page predicate reads one key, so the filter accepts a predicate whose single key is a struct field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The expected output is the output before bloom filters apply to struct fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bloom filter needs the literals that a key must equal. `LiteralGuarantee` only understands columns, so the analysis stands a placeholder column in for each statistics key and maps the result back to the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A struct field leaf holds every non-null value of the field without conversion, so a value missing from its bloom filter is not in the field. Keys that read the same leaf share one bloom filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A struct field has one leaf, but a function from another crate can need more. A shredded variant stores a value in a typed leaf or in a fallback leaf, and the layout differs between files. `ParquetStatisticsResolver` binds an expression to the leaves of one file, and `BoundExprStatistics` reads them. The struct field matcher becomes the built-in resolver, with the same behavior. A source with a custom resolver does not serialize to proto. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fake `variant_get` and a sidecar leaf for a cast use only the public API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Note
Stacked on #27736. GitHub shows the commits of both PRs. Only the last two belong to this one: compare view.
Which issue does this PR close?
GetFieldFunc#21306.Rationale for this change
#27736 prunes Parquet files on struct fields. A function from another crate, such as
variant_geton a shredded Variant, cannot use its Parquet statistics yet. It can need several leaves, and the layout can differ between files.What changes are included in this PR?
feat:the resolver traits. Struct fields become the built-in resolver, with the same behaviortest:resolvers that use only the public APIThis is a draft for discussion of the API. #26282 proposes a capability on the function for the same use case. The right shape is easier to judge with a real Variant implementation.
What is the testing strategy for this PR?
expr_statistics_resolver.rs: a fakevariant_getwith static and dynamic filters, and a resolver that binds in one file and not in another.Are there any user-facing changes?
ParquetStatisticsResolver,BoundExprStatistics,ParquetLeafStatistics,ExprStatisticsKind,leaf_index_by_pathandParquetSource::with_statistics_resolverParquetSourcewith a custom resolver does not serialize to proto🤖 Generated with Claude Code