Skip to content

fix(datafusion): normalize signed zero in remaining filters - #9323

Closed
lance-gatefixer[bot] wants to merge 4 commits into
mainfrom
gatekeeper/fix-9316-1
Closed

lance-gatefixer[bot] wants to merge 4 commits into
mainfrom
gatekeeper/fix-9316-1

Conversation

@lance-gatefixer

@lance-gatefixer lance-gatefixer Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • normalize signed zero once on each operand of non-literal float comparisons
  • lower array_has zero probes to one array_has_any call covering both floating-point zero encodings
  • preserve one evaluation for volatile haystacks and cover scans, label-list indices, NULLs, and empty lists

Root cause

The signed-zero optimizer only handled comparisons that contained a zero literal. Column-to-column comparisons therefore reached Arrow total-order kernels unchanged, and array_has probed only the literal bit pattern, so negative and positive zero compared as different values. Expanding array_has into two OR arms would evaluate a volatile haystack twice, so the repair uses a single two-needle probe.

Validation

Validated after merging main at a801db8 with Rust 1.98.1:

  • cargo fmt --all
  • cargo test -p lance-datafusion --features substrait (278 unit tests and 5 doctests passed)
  • cargo test -p lance --lib --test integration_tests --features substrait,slow_tests signed_zero (codec round-trip and dataset regression passed)
  • cargo clippy --all --tests --benches -- -D warnings

Fixes #9316

@github-actions github-actions Bot added the bug Something isn't working label Sep 16, 2026
@lance-gatefixer

Copy link
Copy Markdown
Contributor Author

Blocked: The Ready PR is blocked by a flaky linux-arm Check that the lance-gatefixer App cannot rerun.

Remote head a4270ba contains the current main tip d073576. Rust workflow run 35160280317, job linux-arm (105009217457), failed only test_legacy_ivf_pq_cosine_multivec_smoke at recall 0.49 versus the 0.50 threshold after 3,894 tests passed; the PR does not change that vector-index path, its KMeans initialization draws an OS-random seed, and focused reruns on this head pass. A failed-job rerun was attempted, but GitHub rejected it because this integration lacks Actions rerun access.

The smallest action is for a maintainer to rerun the failed linux-arm job. Alternatively, grant lance-gatefixer Actions write permission and wake this FixAgent so it can request the rerun.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 16, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 17, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 17, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@jonasdedden

Copy link
Copy Markdown
Contributor

Superseded by #9628, which fixes #9316 together with the NaN sign issue (#9315) using a single normalization UDF, extends the array_has rewrite to NaN, and keeps the Substrait round-trip and array_has coverage requested in the reviews here. Thanks!

westonpace pushed a commit that referenced this pull request Oct 21, 2026
Support SQL `IS [NOT] DISTINCT FROM` in Lance filters, which previously
failed with "not supported SQL".

The planner now maps both spellings to DataFusion's `IsDistinctFrom` /
`IsNotDistinctFrom`, as DataFusion's own SQL frontend does. Literal
coercion, the signed-zero rewrite (`x IS NOT DISTINCT FROM 0.0` matches
both zero encodings) and null-safe evaluation already handle these
operators. Also fixes the `signed_zero.rs` doc table, which described an
outdated rewrite shape.

Column-vs-column signed zeros and NaN still follow Arrow's total order
(#9316, fixed by #9323; #9315).
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 21, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

✅ Gate recommendation: approve.

The main-branch merge preserves signed-zero and NULL behavior, including null-safe comparisons and exact DOUBLE-to-Float32 literal coercion. Normalization remains reconstructible through Substrait, while array_has_any preserves a single evaluation of volatile haystacks and the indexed, null, and empty-list cases. I found no remaining material issue in this revision.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 21, 2026
@Xuanwo

Xuanwo commented Oct 27, 2026

Copy link
Copy Markdown
Member

Superseded by #9628, which fixes #9316 together with #9315 and retains the Substrait and scalar-index coverage.

@Xuanwo Xuanwo closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: -0.0 and 0.0 still compare unequal between columns and in array_has

2 participants