Skip to content

Optimize NULL-containing string IN list pruning - #24954

Merged
kumarUjjawal merged 3 commits into
apache:mainfrom
kumarUjjawal:feat/compact-null-in-list-pruning
Sep 5, 2026
Merged

Optimize NULL-containing string IN list pruning#24954
kumarUjjawal merged 3 commits into
apache:mainfrom
kumarUjjawal:feat/compact-null-in-list-pruning

Conversation

@kumarUjjawal

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#24781 added compact pruning for non-NULL NOT IN lists. Issue #24711 still needs support for NULL-containing lists.

Large string lists can create expensive per-value pruning expressions. The compact path reduces this cost when max_in_list_size permits the rewrite.

NULL values require special handling. Filter pruning treats FALSE and UNKNOWN equally, but full-match detection must keep these results separate.

What changes are included in this PR?

This PR makes these changes:

  • Supports compact pruning for large string IN lists that contain NULL.
  • Treats NOT IN with NULL as unable to match rows.
  • Treats all-NULL IN lists as unable to match rows.
  • Records whether a pruning predicate is safe for full-match inversion.
  • Uses the same configured list-size cap when it builds the inverse predicate.
  • Adds unit tests, Parquet integration tests, documentation, and benchmarks.

What is the testing strategy for this PR?

The tests cover positive and negative lists, all-NULL lists, nested OR expressions, configured caps, and Parquet full-match detection.

These commands passed:

cargo test -p datafusion-pruning
cargo test -p datafusion-datasource-parquet
cargo test -p datafusion --test parquet_integration string_in_list_pruning
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings

Focused benchmarks also cover compact IN and constant-false NOT IN expressions with NULL.

Are there any user-facing changes?

Large string IN and NOT IN lists that contain NULL can now use compact pruning when the cap permits it.

Query results and configuration defaults do not change.

This PR adds two non-breaking PruningPredicate accessors: max_in_list_size and can_be_inverted_for_full_match.

@github-actions github-actions Bot added core Core DataFusion crate common Related to common crate datasource Changes to the datasource crate labels Sep 5, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 5, 2026
@github-actions github-actions Bot added the sqllogictest SQL Logic Tests (.slt) label Sep 5, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.63158% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.61%. Comparing base (35f58f5) to head (169aa64).

Files with missing lines Patch % Lines
datafusion/pruning/src/pruning_predicate.rs 92.30% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24954      +/-   ##
==========================================
- Coverage   81.61%   81.61%   -0.01%     
==========================================
  Files        1124     1124              
  Lines      411978   412054      +76     
  Branches   411978   412054      +76     
==========================================
+ Hits       336236   336298      +62     
- Misses      55936    55944       +8     
- Partials    19806    19812       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jayzhan211 jayzhan211 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kumarUjjawal, LGTM!

@kumarUjjawal

Copy link
Copy Markdown
Contributor Author

Thank you @jayzhan211 for the review.

@kumarUjjawal
kumarUjjawal added this pull request to the merge queue Sep 5, 2026
Merged via the queue into apache:main with commit 33028d5 Sep 5, 2026
39 checks passed
@kumarUjjawal
kumarUjjawal deleted the feat/compact-null-in-list-pruning branch September 5, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate documentation Improvements or additions to documentation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compact IN-list pruning excludes NOT IN and NULL-containing lists

3 participants