IN LIST: retain short lists with specialized filters - #25187
Draft
geoffreyclaude wants to merge 2 commits into
Draft
IN LIST: retain short lists with specialized filters#25187geoffreyclaude wants to merge 2 commits into
geoffreyclaude wants to merge 2 commits into
Conversation
geoffreyclaude
force-pushed
the
codex/in-list-short-rewrite
branch
5 times, most recently
from
September 11, 2026 13:58
0186b14 to
ef1ad44
Compare
12 tasks
geoffreyclaude
force-pushed
the
codex/in-list-short-rewrite
branch
from
September 11, 2026 14:35
ef1ad44 to
11b0a61
Compare
geoffreyclaude
force-pushed
the
codex/in-list-short-rewrite
branch
from
September 14, 2026 12:30
11b0a61 to
41aaaa1
Compare
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.
Which issue does this PR close?
Rationale for this change
On
main, the expression simplifier rewrites singletonINlists, and two- or three-item lists on a column, into left-deepOR/ANDcomparison chains. DataFusion now has specialized staticInListfilters for several physical representations. For supported constant lists, expanding two or three items prevents those specialized physical filters from being used.The rewrite should therefore depend on the available physical representation, not only on list length. This PR retains two- and three-item
InListexpressions when a specialized static filter can evaluate them, while preserving the existing comparison rewrite for dynamic or generic lists.Singleton lists are still simplified to equality. Although singleton
InListevaluation is faster for several representations in isolation, equality remains the canonical logical form and can benefit optimizer and pushdown paths that this microbenchmark does not measure.What changes are included in this PR?
OR/ANDexpansion for generic types, out-of-line byte views, and non-constant lists.What is the testing strategy for this PR?
Coverage includes the retained and expanded boundaries;
INandNOT IN; typed nulls; dynamic lists; nested dictionaries; supported and unsupported fixed-size-binary widths; inline and out-of-lineUtf8View/BinaryViewvalues; and the independent preimage limit.Focused validation on the stacked branch:
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningscargo test -p datafusion-optimizer --lib(808 tests)negative_zerocargo test -p datafusion-substrait roundtrip_inlist(5 tests)cargo check -p datafusion --bench in_list_rewritecargo bench -p datafusion --bench in_list_rewrite -- --noplotThe full extended workspace suite was not run locally; broader coverage is left to CI.
Are there any user-facing changes?
This PR changes optimized plan shape, but does not change query results or public APIs. For supported constant-list representations, optimized plans retain two- and three-item
InListexpressions instead of expanding them into comparison chains.The lower stacked PR, #25186, independently fixes signed-zero equality for retained floating-point lists and must land before this plan-shape change.
Local benchmark snapshot
The new benchmark parses and analyzes both forms from SQL, asserts their physical shapes and equal outputs, then measures only physical-expression evaluation. It covers five representative types; list sizes 1-4; batches of 1, 64, and 8,192 rows; input and list nulls; miss, balanced, and skewed match rates; and both
INandNOT IN: 300 paired scenarios and 600 Criterion functions in total.These indicative measurements were collected locally on an Apple M1 Max (10 cores, 64 GB) with #25187 stacked on #25186. The branch hashes have since changed during rebasing; the benchmark and optimizer logic measured here are unchanged. Absolute timings are machine-specific.
The table focuses on the two sizes whose optimizer policy changes. Each ratio is the median
comparison chain / retained InListtime across 16 scenarios; values above 1 favor retainingInList.FixedSizeBinary(8)Float64Int32Utf8ViewUtf8OR/ANDGeneric
Utf8remains mixed, including regressions for skewed and null-containing lists, so this PR deliberately leaves it on the existing comparison rewrite. List sizes one and four serve as boundary controls; their optimizer policy is unchanged.