IN LIST: treat signed zeros as equal - #25186
geoffreyclaude wants to merge 1 commit into
Conversation
12098fc to
474474f
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #25186 +/- ##
========================================
Coverage 81.91% 81.91%
========================================
Files 1134 1134
Lines 425637 425900 +263
Branches 425637 425900 +263
========================================
+ Hits 348654 348881 +227
- Misses 56302 56316 +14
- Partials 20681 20703 +22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e0f44e0 to
aa5a037
Compare
| let normalized: Float32Array = | ||
| arr.unary(|v| if v.to_bits() << 1 == 0 { 0.0_f32 } else { v }); | ||
| let normalized: Float32Array = arr.unary(|v| { | ||
| if v.to_bits() == NEG_ZERO_F32_BITS { |
There was a problem hiding this comment.
Only NEG_ZERO_F32_BITS needs a change, so compare directly against it
| let normalized: Float64Array = | ||
| arr.unary(|v| if v.to_bits() << 1 == 0 { 0.0_f64 } else { v }); | ||
| let normalized: Float64Array = arr.unary(|v| { | ||
| if v.to_bits() == NEG_ZERO_F64_BITS { |
There was a problem hiding this comment.
Only NEG_ZERO_F64_BITS needs a change, so compare directly against it
aa5a037 to
eaee11e
Compare
eaee11e to
8713a66
Compare
|
run benchmark in_list_strategy |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing codex/in-list-signed-zero (8713a66) to 7b00b63 (merge-base) diff Run configurationrun benchmark in_list_strategyResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing codex/in-list-signed-zero (8713a66) to 7b00b63 (merge-base) diff Run configurationrun benchmark in_list_strategyCPU Details (lscpu)Details
Resource Usagein_list_strategy — base (merge-base)
in_list_strategy — branch
File an issue against this benchmark runner |
Which issue does this PR close?
None
Rationale for this change
DataFusion equality treats
+0.0and-0.0as equal, but the optimizedINfilters compare or hash floating-point bit patterns. Because the two zeros have different encodings, anINpredicate could therefore return a different result depending on whether the optimizer retained it or rewrote it into equality comparisons.This PR makes top-level
Float16,Float32, andFloat64INpredicates follow the same signed-zero equality as ordinary comparisons. Static filters materialize both zero encodings once while building the list, keeping lookup on the row path branch-free. Non-static lists normalize evaluated floating operands once per batch. Distinct NaN payloads remain distinct, preserving the existing bit-equality behavior for NaNs.What changes are included in this PR?
Float16bitmap andFloat32/Float64hash-set filters.IN, andNOT IN.Are these changes tested?
The SQL logic tests cover both signed-zero directions for
Float16,Float32, andFloat64; comparison-rewritten, static-filter, and non-static-list paths; dictionary-encodedFloat64; and bothINandNOT IN. The added cases fail on the parent commit and pass with this fix.Focused validation:
cargo test -p datafusion-common normalize_float_zerocargo test -p datafusion-physical-expr in_list(88 tests)cargo test -p datafusion-sqllogictest --test sqllogictests -- negative_zeroAre there any user-facing changes?
Yes. Floating-point
INandNOT INnow treat+0.0and-0.0as equal, consistently with ordinary DataFusion equality. There are no public API changes.