Skip to content

feat: support floating-point ASOF equality keys - #24375

Draft
Xuanwo wants to merge 15 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-float-equality
Draft

feat: support floating-point ASOF equality keys#24375
Xuanwo wants to merge 15 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-float-equality

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Aug 14, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

The physical ASOF operator in #23828 rejects floating-point equality keys because
Arrow's total ordering distinguishes -0.0 from +0.0, while join equality
treats them as equal. That mismatch can split one equality group during the
required input sort and make the forward-only ASOF scan choose the wrong row.

This follow-up keeps the independently mergeable physical operator conservative,
then adds complete Float16, Float32, and Float64 equality-key support as a
separate stack layer.

GitHub shows the cumulative stack because fork branches cannot be selected as
upstream PR bases. The isolated diff for this layer is:
Xuanwo/datafusion@xuanwo/asof-physical...xuanwo/asof-float-equality

What changes are included in this PR?

  • Add an order-preserving NormalizeFloatZeroExpr that maps -0.0 to
    +0.0 without changing other values.
  • Use the expression only for floating-point ASOF equality-key ordering, so the
    required sort order agrees with the existing join-key comparator.
  • Add protobuf encode/decode support so plans containing the required sort
    expression round-trip correctly.
  • Add a regression covering Float16, Float32, and Float64 where
    (-0.0, ts=10) followed by (+0.0, ts=1) must remain one group and select
    ts=1 for a left (+0.0, ts=5) row.

Are these changes tested?

Yes:

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • ASOF physical operator tests, including all three floating-point types
  • Logical and physical protobuf round-trip tests
  • Extended workspace tests from the contributor guide
  • FFI integration tests

Are there any user-facing changes?

ASOF equality keys can use Float16, Float32, and Float64 while treating signed
zero consistently with join equality. This layer also adds a public physical
expression and an append-only protobuf oneof variant; existing wire tags are not
reused.

@github-actions

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion-physical-expr v54.1.0 (current)
       Built [  30.778s] (current)
     Parsing datafusion-physical-expr v54.1.0 (current)
      Parsed [   0.055s] (current)
    Building datafusion-physical-expr v54.1.0 (baseline)
       Built [  29.122s] (baseline)
     Parsing datafusion-physical-expr v54.1.0 (baseline)
      Parsed [   0.054s] (baseline)
    Checking datafusion-physical-expr v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.529s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  61.903s] datafusion-physical-expr
    Building datafusion-physical-plan v54.1.0 (current)
       Built [  37.535s] (current)
     Parsing datafusion-physical-plan v54.1.0 (current)
      Parsed [   0.157s] (current)
    Building datafusion-physical-plan v54.1.0 (baseline)
       Built [  37.410s] (baseline)
     Parsing datafusion-physical-plan v54.1.0 (baseline)
      Parsed [   0.154s] (baseline)
    Checking datafusion-physical-plan v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   1.000s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  77.629s] datafusion-physical-plan
    Building datafusion-proto v54.1.0 (current)
       Built [  53.185s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.019s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  53.612s] (baseline)
     Parsing datafusion-proto v54.1.0 (baseline)
      Parsed [   0.020s] (baseline)
    Checking datafusion-proto v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.167s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 108.576s] datafusion-proto
    Building datafusion-proto-models v54.1.0 (current)
       Built [  24.895s] (current)
     Parsing datafusion-proto-models v54.1.0 (current)
      Parsed [   0.138s] (current)
    Building datafusion-proto-models v54.1.0 (baseline)
       Built [  24.850s] (baseline)
     Parsing datafusion-proto-models v54.1.0 (baseline)
      Parsed [   0.137s] (baseline)
    Checking datafusion-proto-models v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   2.557s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/enum_variant_added.ron

Failed in:
  variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1626
  variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1626

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  54.238s] datafusion-proto-models

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Aug 14, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.35411% with 348 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (ec110ce) to head (e570325).

Files with missing lines Patch % Lines
datafusion/physical-plan/src/joins/asof_join.rs 79.71% 191 Missing and 65 partials ⚠️
datafusion/proto-models/src/generated/pbjson.rs 0.00% 57 Missing ⚠️
...sical-expr/src/expressions/normalize_float_zero.rs 63.04% 29 Missing and 5 partials ⚠️
datafusion/proto/src/physical_plan/from_proto.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24375      +/-   ##
==========================================
- Coverage   81.19%   81.17%   -0.02%     
==========================================
  Files        1110     1112       +2     
  Lines      388618   390030    +1412     
  Branches   388618   390030    +1412     
==========================================
+ Hits       315531   316601    +1070     
- Misses      54507    54773     +266     
- Partials    18580    18656      +76     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants