Skip to content

IN LIST: centralize primitive filters and optimize Decimal128 - #24283

Draft
geoffreyclaude wants to merge 5 commits into
apache:mainfrom
geoffreyclaude:codex/in-list-primitive-selector-decimal
Draft

IN LIST: centralize primitive filters and optimize Decimal128#24283
geoffreyclaude wants to merge 5 commits into
apache:mainfrom
geoffreyclaude:codex/in-list-primitive-selector-decimal

Conversation

@geoffreyclaude

@geoffreyclaude geoffreyclaude commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#23014 adds fast direct comparisons for short primitive IN lists. For longer lists, DataFusion uses a bitmap, a hash set, or another specialized filter when one exists, and otherwise uses the general filter.

#24102 needs to make that same choice after reading FixedSizeBinary values as same-width primitive keys. Today, the choice is part of the native primitive path, so #24102 would have to repeat its limits and fallback rules.

This PR moves that choice beside the primitive filters and makes it reusable. The limits count only non-null list values. A separate commit uses one PrimitiveHashSetFilter<T, K> for the existing integer and floating-point hash-set paths. Integers keep their native keys; Float32 and Float64 keep their bitwise keys, including distinct signed zeros and NaN encodings. Filter selection and SQL behavior are unchanged.

The only new lookup path is for Decimal128. Lists with at most four non-null values still use direct comparisons. Larger lists now use a hash set over the stored i128 values instead of the general Arrow filter. Values are not rescaled, and the existing precision, scale, and null rules are unchanged. #24102 also uses this path for 16-byte FixedSizeBinary values.

What changes are included in this PR?

  • Makes primitive filter selection reusable by IN LIST: reuse primitive filters for FixedSizeBinary #24102.
  • Uses one primitive hash-set implementation for integer and floating-point values, while preserving their existing key semantics.
  • Uses PrimitiveHashSetFilter<Decimal128Type> for Decimal128 lists with more than four non-null values.
  • Adds four Decimal128 benchmark cases at list sizes 5 and 64.

Are these changes tested?

Tests cover the direct-comparison boundary, an all-null list, and bitwise float hash keys, including signed zero and distinct NaN encodings. Existing end-to-end Decimal tests cover hits, misses, nulls, IN, and NOT IN.

Are there any user-facing changes?

No. SQL results and public APIs are unchanged.

Benchmark snapshot

The benchmark uses list size 5, the first size above the direct-comparison limit, and a larger size of 64. Each size is measured with 0% and 50% matches. Filter construction is outside the timed loop.

A previous automated run measured this lookup strategy before the work was split from #24102. The current code still probes a hash set of stored i128 values, and filter construction remains outside the timed loop.

Compared baselines: #23014 -> this PR

Benchmark Before After Change
primitive/decimal128/large_list/list=5/match=0% 18.1 us 15.2 us -16.0% (1.19x faster)
primitive/decimal128/large_list/list=5/match=50% 38.6 us 19.2 us -50.3% (2.01x faster)
primitive/decimal128/large_list/list=64/match=0% 17.6 us 15.2 us -13.6% (1.16x faster)
primitive/decimal128/large_list/list=64/match=50% 37.1 us 23.5 us -36.7% (1.58x faster)

@codecov-commenter

codecov-commenter commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.14%. Comparing base (426b351) to head (510bf3e).
⚠️ Report is 106 commits behind head on main.

Files with missing lines Patch % Lines
...l-expr/src/expressions/in_list/primitive_filter.rs 73.79% 23 Missing and 15 partials ⚠️
.../physical-expr/src/expressions/in_list/strategy.rs 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24283      +/-   ##
==========================================
+ Coverage   80.91%   81.14%   +0.23%     
==========================================
  Files        1102     1112      +10     
  Lines      377102   386940    +9838     
  Branches   377102   386940    +9838     
==========================================
+ Hits       305143   313998    +8855     
- Misses      53769    54439     +670     
- Partials    18190    18503     +313     

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

@geoffreyclaude
geoffreyclaude force-pushed the codex/in-list-primitive-selector-decimal branch 7 times, most recently from 00885e0 to 65b1e9f Compare August 13, 2026 10:14
Use PrimitiveHashSetFilter<T, K> for integer and floating-point arrays. Integer filters keep their native key type by default; Float32 and Float64 use their existing bitwise wrapper keys, preserving signed-zero and NaN-payload behavior.

The key type and conversion are selected statically, with no function pointer or dynamic dispatch in the lookup loop. Filter selection, dictionary handling, null handling, IN, and NOT IN behavior remain unchanged. Decimal128 routing remains in the following commit.
Route Decimal128 lists above the branchless cutoff through PrimitiveHashSetFilter, replacing the ArrayStaticFilter fallback.
@geoffreyclaude
geoffreyclaude force-pushed the codex/in-list-primitive-selector-decimal branch from 65b1e9f to 510bf3e Compare August 13, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants