rgbuilds opened a new pull request, #27658:
URL: https://github.com/apache/datafusion/pull/27658

   ## Which issue does this PR close?
   
   - Closes #27415.
   
   ## Rationale for this change
   
   #27415 reports that enabling `datafusion.execution.collect_statistics` could 
lose Parquet row-group pruning when a predicate combined expressions supported 
by statistics with an expression that statistics could not evaluate. For 
example:
   
   ```sql
   body = 'x'
   OR (
     body IS NULL
     AND tid = 1
     AND array_element(seps, 1) = ''
   )
   ```
   
   For a file where `body` is entirely NULL and `tid` is always 9, the 
supported predicates prove that no row can match. The non-prunable 
`array_element` term must be handled conservatively as "may match" at its own 
subtree, without discarding useful information from the supported sibling 
predicates.
   
   The issue reproduces on the release identified in #27415, but it no longer 
reproduces on current `main`. The file-statistics pruning added by #26441 now 
removes the impossible file before its Parquet opener runs when statistics 
collection is enabled. Without collected file statistics, the existing Parquet 
footer path still prunes the impossible row group.
   
   As a result, an additional production-code fix does not appear necessary on 
current `main`. This PR adds focused regression coverage for the original 
predicate and documents the expected behavior of both pruning paths.
   
   ## What changes are included in this PR?
   
   This PR adds 
`prune_mixed_supported_and_unsupported_predicate_with_file_statistics` to the 
Parquet row-group pruning integration tests.
   
   The test creates three single-row-group Parquet files:
   
   1. `matches`: the supported predicates and `array_element` comparison all 
match. The file must be retained and the query returns its row.
   2. `unsupported_does_not_match`: the supported predicates can match, but the 
`array_element` comparison is false. Statistics cannot prove that, so the file 
must be retained and normal row filtering later removes the row.
   3. `cannot_match`: `body` is entirely NULL and `tid` is always 9, while the 
`array_element` comparison is true. The supported predicates alone prove that 
the file cannot match, so the unsupported expression must not prevent pruning.
   
   The query runs with `collect_statistics` both disabled and enabled. It first 
checks all three files together and then checks each file independently. The 
individual checks ensure aggregate metrics cannot hide an incorrect 
implementation that prunes the conservatively retained file while retaining the 
actually impossible file.
   
   The assertions cover:
   
   - Concrete query results for each scenario.
   - Files opened.
   - Row groups retained or pruned by Parquet statistics.
   - Complete removal of the Parquet scan when collected file statistics 
eliminate the only input file during planning.
   
   No production code or public API is changed.
   
   ## What is the testing strategy for this PR?
   
   The new regression test exercises the exact mixed prunable/non-prunable 
predicate under both values of `collect_statistics` and verifies query 
correctness as well as pruning behavior.
   
   The following targeted checks pass:
   
   ```console
   cargo test -p datafusion --test parquet_integration \
     
row_group_pruning::prune_mixed_supported_and_unsupported_predicate_with_file_statistics
 \
     -- --nocapture
   
   cargo fmt --all
   
   cargo clippy -p datafusion --all-targets --all-features -- -D warnings
   
   git diff --check
   ```
   
   ## Are there any user-facing changes?
   
   No. Query results, public APIs, and configuration behavior are unchanged. 
Current `main` already performs the desired pruning through the file-statistics 
path introduced by #26441; this PR protects that behavior with focused 
regression coverage.
   


-- 
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]

Reply via email to