Skip to content

feat: add ASOF joins to DataFrame API - #23831

Draft
Xuanwo wants to merge 14 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-dataframe
Draft

feat: add ASOF joins to DataFrame API#23831
Xuanwo wants to merge 14 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-dataframe

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Jul 23, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

This is the DataFrame API layer of the ASOF JOIN stack. It exposes the logical
contract through the fluent API without coupling that API review to SQL parsing
or protobuf changes.

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-logical...xuanwo/asof-dataframe

What changes are included in this PR?

  • Add DataFrame::join_asof for expression-based equality keys.
  • Add DataFrame::join_asof_using for same-named equality keys.
  • Export AsOfMatch and Operator from the DataFusion prelude.
  • Add a DataFrame-only execution test that exercises the broadcast physical
    operator without depending on SQL syntax.

Are these changes tested?

Yes:

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test -p datafusion --test core_integration dataframe::join_asof --all-features

Are there any user-facing changes?

Users can build ASOF joins through DataFrame::join_asof and
DataFrame::join_asof_using. The USING form follows DataFusion's existing
name-resolution contract: wildcard output exposes one unqualified key while
both qualified input keys remain addressable.

This PR should be reviewed and merged after #23829. After its dependencies
squash-merge, this branch will be refreshed from main without rewriting its
published history.

@github-actions github-actions Bot added sql SQL Planner logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate substrait Changes to the substrait crate proto Related to proto crate physical-plan Changes to the physical-plan crate labels Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

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 v54.1.0 (current)
       Built [  76.461s] (current)
     Parsing datafusion v54.1.0 (current)
      Parsed [   0.026s] (current)
    Building datafusion v54.1.0 (baseline)
       Built [  76.805s] (baseline)
     Parsing datafusion v54.1.0 (baseline)
      Parsed [   0.027s] (baseline)
    Checking datafusion v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.760s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 156.044s] datafusion
    Building datafusion-expr v54.1.0 (current)
       Built [  21.716s] (current)
     Parsing datafusion-expr v54.1.0 (current)
      Parsed [   0.063s] (current)
    Building datafusion-expr v54.1.0 (baseline)
       Built [  21.373s] (baseline)
     Parsing datafusion-expr v54.1.0 (baseline)
      Parsed [   0.057s] (baseline)
    Checking datafusion-expr v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   1.681s] 223 checks: 222 pass, 1 fail, 0 warn, 30 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.49.0/src/lints/enum_variant_added.ron

Failed in:
  variant LogicalPlan:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/expr/src/logical_plan/plan.rs:301
  variant LogicalPlan:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/expr/src/logical_plan/plan.rs:301

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  46.015s] datafusion-expr
    Building datafusion-optimizer v54.1.0 (current)
       Built [  22.883s] (current)
     Parsing datafusion-optimizer v54.1.0 (current)
      Parsed [   0.028s] (current)
    Building datafusion-optimizer v54.1.0 (baseline)
       Built [  22.208s] (baseline)
     Parsing datafusion-optimizer v54.1.0 (baseline)
      Parsed [   0.026s] (baseline)
    Checking datafusion-optimizer v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.212s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  46.376s] datafusion-optimizer
    Building datafusion-physical-plan v54.1.0 (current)
       Built [  30.885s] (current)
     Parsing datafusion-physical-plan v54.1.0 (current)
      Parsed [   0.110s] (current)
    Building datafusion-physical-plan v54.1.0 (baseline)
       Built [  29.962s] (baseline)
     Parsing datafusion-physical-plan v54.1.0 (baseline)
      Parsed [   0.111s] (baseline)
    Checking datafusion-physical-plan v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.859s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  63.313s] datafusion-physical-plan
    Building datafusion-proto v54.1.0 (current)
       Built [  50.487s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.014s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  47.009s] (baseline)
     Parsing datafusion-proto v54.1.0 (baseline)
      Parsed [   0.016s] (baseline)
    Checking datafusion-proto v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.296s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  99.626s] datafusion-proto
    Building datafusion-sql v54.1.0 (current)
       Built [  31.995s] (current)
     Parsing datafusion-sql v54.1.0 (current)
      Parsed [   0.025s] (current)
    Building datafusion-sql v54.1.0 (baseline)
       Built [  32.415s] (baseline)
     Parsing datafusion-sql v54.1.0 (baseline)
      Parsed [   0.025s] (baseline)
    Checking datafusion-sql v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.284s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  66.096s] datafusion-sql
    Building datafusion-substrait v54.1.0 (current)
       Built [ 250.476s] (current)
     Parsing datafusion-substrait v54.1.0 (current)
      Parsed [   0.014s] (current)
    Building datafusion-substrait v54.1.0 (baseline)
       Built [ 244.161s] (baseline)
     Parsing datafusion-substrait v54.1.0 (baseline)
      Parsed [   0.014s] (baseline)
    Checking datafusion-substrait v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.258s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 497.830s] datafusion-substrait

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

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.48943% with 356 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.66%. Comparing base (e8a65f2) to head (082dc0b).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/physical-plan/src/joins/asof_join.rs 86.04% 107 Missing and 64 partials ⚠️
datafusion/expr/src/logical_plan/plan.rs 49.46% 80 Missing and 14 partials ⚠️
datafusion/optimizer/src/push_down_filter.rs 0.00% 24 Missing ⚠️
datafusion/expr/src/logical_plan/builder.rs 59.64% 17 Missing and 6 partials ⚠️
datafusion/core/src/dataframe/mod.rs 43.33% 15 Missing and 2 partials ⚠️
datafusion/expr/src/logical_plan/display.rs 0.00% 10 Missing ⚠️
datafusion/core/src/physical_planner.rs 83.72% 5 Missing and 2 partials ⚠️
datafusion/expr/src/logical_plan/tree_node.rs 93.02% 0 Missing and 3 partials ⚠️
datafusion/proto/src/logical_plan/mod.rs 0.00% 3 Missing ⚠️
datafusion/optimizer/src/analyzer/type_coercion.rs 92.85% 1 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23831      +/-   ##
==========================================
- Coverage   80.66%   80.66%   -0.01%     
==========================================
  Files        1095     1096       +1     
  Lines      372294   374112    +1818     
  Branches   372294   374112    +1818     
==========================================
+ Hits       300324   301783    +1459     
- Misses      54055    54305     +250     
- Partials    17915    18024     +109     

☔ 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 core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules physical-plan Changes to the physical-plan crate proto Related to proto crate sql SQL Planner substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants