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

   ## Which issue does this PR close?
   
   Closes #24708.
   
   ## Rationale for this change
   
   Large `IN` filters can prevent DataFusion from skipping Parquet row groups 
and pages, even when their statistics show they cannot contain any of the 
requested values. This is especially costly when the values are clustered in a 
narrow range.
   
   ## What changes are included in this PR?
   
   When compact pruning isn't available for a positive `IN` list, DataFusion 
now tries to compute the minimum and maximum literal values in one pass. It 
skips containers whose statistics don't overlap that range. If both bounds are 
equal, it uses an equality check. The range is used only for pruning; the 
original `IN` filter still determines which rows match.
   
   The fallback ignores `NULL` literals and is not used for NULL-only lists, 
non-literal expressions, NaNs, or unsupported types. `NOT IN` is unchanged, and 
`max_in_list_size = 0` still disables `IN`-list pruning.
   
   ### Benchmarks
   
   Local Criterion comparison against `main` using `release-nonlto`, 1,024 list 
values, and 4,096 disjoint `Int64` containers. Lower container counts mean more 
pruning.
   
   | Case | Containers kept (main → branch) | Build time (main → branch) | 
Pruning time (main → branch) |
   | --- | ---: | ---: | ---: |
   | Clustered `IN` | 4,096 → 21 | 153.79 µs → 191.13 µs | 261.47 ns → 39.72 µs 
|
   | Scattered `IN` | 4,096 → 4,093 | 152.57 µs → 183.19 µs | 288.64 ns → 36.81 
µs |
   | `NOT IN` | 4,096 → 4,096 | 169.60 µs → 156.31 µs | 287.81 ns → 283.96 ns |
   | Compact `IN` | 21 → 21 | 177.29 µs → 178.82 µs | 116.32 µs → 120.47 µs |
   
   The fallback pruned 99.5% of containers for the clustered list. The 
scattered list shows the tradeoff: about 31 µs more to build the predicate and 
37 µs more to evaluate it, with only three containers pruned. These timings 
measure pruning, not end-to-end query runtime.
   
   ## What is the testing strategy for this PR?
   
   Added unit tests in `pruning_predicate.rs` for range pruning, equal bounds, 
NULLs, NaNs, `NOT IN`, the opt-out, and inverted statistics bounds. Added 
Parquet row-group and page-index tests in `string_in_list_pruning.rs` for 
`Int64`, signed zero, and fixed-size binary, plus SQL coverage in 
`parquet_statistics.slt` and `information_schema.slt`.
   
   Verification on `7455d99`:
   
   - `datafusion-pruning`: 121 passed.
   - `datafusion-datasource-parquet`: 315 unit tests and 5 doc tests passed.
   - `parquet_integration`: 265 passed.
   - `parquet_statistics` and `information_schema` sqllogictests: 5 passed.
   - Formatting, Clippy and rustdoc with warnings denied, and generated-doc 
checks passed.
   
   ## Are there any user-facing changes?
   
   Eligible large `IN` filters can now skip Parquet row groups and pages using 
min/max statistics without changing query results. Updated the documentation 
for `datafusion.execution.parquet.max_in_list_size` and regenerated the 
configuration reference.
   
   


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