adriangb opened a new pull request, #27877: URL: https://github.com/apache/datafusion/pull/27877
## Which issue does this PR close? - None. This PR is a preparatory step split out of https://github.com/apache/datafusion/pull/27736. ## Rationale for this change `PagesPruningStatistics` in `datafusion/datasource-parquet/src/page_filter.rs` implements `PruningStatistics` for one Parquet column. Its `min_values`, `max_values` and `null_counts` methods ignore the `column` argument. They always return the statistics of the column that the struct was built for. Page pruning is correct only because the caller first calls `RequiredColumns::single_column`. That is a hidden contract between two crates. This PR makes the statistics answer only for their own column. It also moves the "one column only" rule into the page filter, the only code that uses it. ## What changes are included in this PR? Review the PR commit by commit. | Commit | Change | |---|---| | 1. `refactor: let PagesPruningStatistics answer only for its own column` | `min_values`, `max_values` and `null_counts` return `None` for any column other than the one that the `StatisticsConverter` describes. A unit test covers this. | | 2. `refactor: decide the page filter's single column in the page filter` | `RequiredColumns` gets a public `columns()` accessor. A private `single_column` helper in `page_filter.rs` replaces the four calls to `RequiredColumns::single_column`. That method is deprecated. | The helper: ```rust fn single_column(predicate: &PruningPredicate) -> Option<&Column> { let mut columns = predicate.required_columns().columns(); let first = columns.next()?; columns.all(|c| c == first).then_some(first) } ``` Neither commit changes query behavior. ## What is the testing strategy for this PR? The new unit test `pages_pruning_statistics_answer_only_for_own_column` in `page_filter.rs` writes a two-column file with two pages per column. It builds `PagesPruningStatistics` for column `a` and asserts these exact values: | Call | Expected | |---|---| | `min_values(a)` | `[1, 4]` | | `max_values(a)` | `[2, 4]` | | `null_counts(a)` | `[0, 1]` | | `min_values(b)`, `max_values(b)`, `null_counts(b)` | `None` | One pruning test used `single_column()` to check that the predicate needs only column `c1`. It now checks the same fact with `columns()`. The existing page index tests in `datafusion/core/tests/parquet/`, the `datafusion-pruning` tests and the Parquet sqllogictests pass. ## Are there any user-facing changes? Yes, in the `datafusion-pruning` API: - New: `RequiredColumns::columns()`. It returns an iterator over the column of each required statistic. A column can appear more than once. - Deprecated since 57.0.0: `RequiredColumns::single_column()`. Use `columns()` and compare the columns instead. There is no breaking change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
