Skip to content

feat: serialize ASOF join plans - #23832

Draft
Xuanwo wants to merge 3 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-proto
Draft

feat: serialize ASOF join plans#23832
Xuanwo wants to merge 3 commits into
apache:mainfrom
Xuanwo:xuanwo/asof-proto

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 serialization layer of the ASOF JOIN stack. It gives logical and
physical ASOF plans explicit protobuf representations without coupling wire
format review to SQL or DataFrame APIs.

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-proto

What changes are included in this PR?

  • Add protobuf messages and enum values for logical and physical ASOF joins.
  • Encode and decode equality keys, ordered match expressions, match direction,
    join constraint, and right output indices.
  • Implement physical serialization through ExecutionPlan::try_to_proto and
    AsOfJoinExec::try_from_proto, following the current self-serializing
    execution-plan pattern.
  • Regenerate prost and pbjson sources with the repository generator.
  • Add logical round trips for all four match directions and a physical
    AsOfJoinExec round trip.

Are these changes tested?

Yes:

  • ./datafusion/proto-models/regen.sh
  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test -p datafusion-proto roundtrip_asof_join --all-features

Are there any user-facing changes?

Logical and physical ASOF join plans can be serialized through
datafusion-proto. The additions use new messages and append-only oneof/enum
tags, so existing wire tags are not reused. Generated public Rust enums gain new
variants, however, so downstream exhaustive matches must add arms; this is a
Rust source-compatibility break even though the wire additions are compatible.

This PR should be reviewed and merged after #23829. As its dependencies merge,
this branch will be restacked onto the latest main.

@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 v55.0.0 (current)
       Built [  49.633s] (current)
     Parsing datafusion v55.0.0 (current)
      Parsed [   0.029s] (current)
    Building datafusion v55.0.0 (baseline)
       Built [  49.973s] (baseline)
     Parsing datafusion v55.0.0 (baseline)
      Parsed [   0.032s] (baseline)
    Checking datafusion v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.740s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 102.486s] datafusion
    Building datafusion-expr v55.0.0 (current)
       Built [  25.315s] (current)
     Parsing datafusion-expr v55.0.0 (current)
      Parsed [   0.066s] (current)
    Building datafusion-expr v55.0.0 (baseline)
       Built [  24.473s] (baseline)
     Parsing datafusion-expr v55.0.0 (baseline)
      Parsed [   0.065s] (baseline)
    Checking datafusion-expr v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   1.527s] 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 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 [  52.623s] datafusion-expr
    Building datafusion-optimizer v55.0.0 (current)
       Built [  22.586s] (current)
     Parsing datafusion-optimizer v55.0.0 (current)
      Parsed [   0.026s] (current)
    Building datafusion-optimizer v55.0.0 (baseline)
       Built [  22.919s] (baseline)
     Parsing datafusion-optimizer v55.0.0 (baseline)
      Parsed [   0.026s] (baseline)
    Checking datafusion-optimizer v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.179s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  46.431s] datafusion-optimizer
    Building datafusion-physical-expr v55.0.0 (current)
       Built [  24.067s] (current)
     Parsing datafusion-physical-expr v55.0.0 (current)
      Parsed [   0.040s] (current)
    Building datafusion-physical-expr v55.0.0 (baseline)
       Built [  24.047s] (baseline)
     Parsing datafusion-physical-expr v55.0.0 (baseline)
      Parsed [   0.041s] (baseline)
    Checking datafusion-physical-expr v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.385s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  49.483s] datafusion-physical-expr
    Building datafusion-physical-plan v55.0.0 (current)
       Built [  31.856s] (current)
     Parsing datafusion-physical-plan v55.0.0 (current)
      Parsed [   0.124s] (current)
    Building datafusion-physical-plan v55.0.0 (baseline)
       Built [  31.047s] (baseline)
     Parsing datafusion-physical-plan v55.0.0 (baseline)
      Parsed [   0.126s] (baseline)
    Checking datafusion-physical-plan v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.799s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  64.941s] datafusion-physical-plan
    Building datafusion-proto v55.0.0 (current)
       Built [  43.959s] (current)
     Parsing datafusion-proto v55.0.0 (current)
      Parsed [   0.015s] (current)
    Building datafusion-proto v55.0.0 (baseline)
       Built [  44.098s] (baseline)
     Parsing datafusion-proto v55.0.0 (baseline)
      Parsed [   0.016s] (baseline)
    Checking datafusion-proto v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.123s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  89.785s] datafusion-proto
    Building datafusion-proto-models v55.0.0 (current)
       Built [  20.347s] (current)
     Parsing datafusion-proto-models v55.0.0 (current)
      Parsed [   0.110s] (current)
    Building datafusion-proto-models v55.0.0 (baseline)
       Built [  21.385s] (baseline)
     Parsing datafusion-proto-models v55.0.0 (baseline)
      Parsed [   0.109s] (baseline)
    Checking datafusion-proto-models v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   2.059s] 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 PhysicalPlanType:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1457
  variant PhysicalPlanType:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1457
  variant LogicalPlanType:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:83
  variant LogicalPlanType:AsOfJoin in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:83
  variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1657
  variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1657

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  45.351s] datafusion-proto-models
    Building datafusion-sql v55.0.0 (current)
       Built [  34.664s] (current)
     Parsing datafusion-sql v55.0.0 (current)
      Parsed [   0.026s] (current)
    Building datafusion-sql v55.0.0 (baseline)
       Built [  34.482s] (baseline)
     Parsing datafusion-sql v55.0.0 (baseline)
      Parsed [   0.028s] (baseline)
    Checking datafusion-sql v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.276s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  70.361s] datafusion-sql
    Building datafusion-substrait v55.0.0 (current)
       Built [ 251.042s] (current)
     Parsing datafusion-substrait v55.0.0 (current)
      Parsed [   0.016s] (current)
    Building datafusion-substrait v55.0.0 (baseline)
       Built [ 249.736s] (baseline)
     Parsing datafusion-substrait v55.0.0 (baseline)
      Parsed [   0.014s] (baseline)
    Checking datafusion-substrait v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.279s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 504.150s] 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 32.67241% with 781 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (0eecdfc) to head (6ae0de3).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-models/src/generated/pbjson.rs 0.00% 398 Missing ⚠️
datafusion/expr/src/logical_plan/plan.rs 38.70% 100 Missing and 14 partials ⚠️
datafusion/expr/src/logical_plan/tree_node.rs 0.00% 43 Missing ⚠️
datafusion/core/src/physical_planner.rs 0.00% 41 Missing ⚠️
...sical-expr/src/expressions/normalize_float_zero.rs 63.04% 29 Missing and 5 partials ⚠️
datafusion/physical-plan/src/joins/asof_join.rs 84.61% 13 Missing and 17 partials ⚠️
datafusion/optimizer/src/analyzer/type_coercion.rs 0.00% 28 Missing ⚠️
datafusion/proto/src/logical_plan/mod.rs 55.73% 17 Missing and 10 partials ⚠️
datafusion/optimizer/src/push_down_filter.rs 0.00% 24 Missing ⚠️
datafusion/proto-models/src/generated/prost.rs 0.00% 17 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23832      +/-   ##
==========================================
- Coverage   81.31%   81.17%   -0.15%     
==========================================
  Files        1117     1118       +1     
  Lines      395987   397112    +1125     
  Branches   395987   397112    +1125     
==========================================
+ Hits       321993   322338     +345     
- Misses      55177    55899     +722     
- Partials    18817    18875      +58     

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

@github-actions github-actions Bot added the physical-expr Changes to the physical-expr crates label Aug 14, 2026
@Xuanwo
Xuanwo force-pushed the xuanwo/asof-proto branch from 19940d8 to 6ae0de3 Compare August 20, 2026 17:56
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-expr Changes to the physical-expr crates 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