Skip to content

fix(proto): serialize Global/LocalLimitExec required_ordering - #24183

Open
buraksenn wants to merge 4 commits into
apache:mainfrom
buraksenn:24173-fix-required-ordering-not-serialized
Open

fix(proto): serialize Global/LocalLimitExec required_ordering#24183
buraksenn wants to merge 4 commits into
apache:mainfrom
buraksenn:24173-fix-required-ordering-not-serialized

Conversation

@buraksenn

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

GlobalLimitExec/LocalLimitExec required_ordering is not serialized, so a roundtrip loses the only record that a pushed-down LIMIT is order-sensitive. Re-running LimitPushdown on the decoded plan then sets preserve_order: false on the scan, which is free to read files out of order — ORDER BY ... LIMIT can return the wrong rows.

What changes are included in this PR?

  • Add required_ordering to GlobalLimitExecNode (field 4) and LocalLimitExecNode (field 3); empty list means None
  • New optional_ordering_try_to_proto/optional_ordering_try_from_proto helpers in physical-expr-common, also reused by SymmetricHashJoinExec serde which hand-rolled the same pattern
  • Preserve required_ordering in both execs' with_new_children

Are these changes tested?

Yes new tests that would fail on main if not fixed

Are there any user-facing changes?

No

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates proto Related to proto crate physical-plan Changes to the physical-plan crate labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 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 [ 110.701s] (current)
     Parsing datafusion v54.1.0 (current)
      Parsed [   0.037s] (current)
    Building datafusion v54.1.0 (baseline)
       Built [ 108.058s] (baseline)
     Parsing datafusion v54.1.0 (baseline)
      Parsed [   0.039s] (baseline)
    Checking datafusion v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.911s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 222.236s] datafusion
    Building datafusion-physical-expr-common v54.1.0 (current)
       Built [  24.429s] (current)
     Parsing datafusion-physical-expr-common v54.1.0 (current)
      Parsed [   0.023s] (current)
    Building datafusion-physical-expr-common v54.1.0 (baseline)
       Built [  24.141s] (baseline)
     Parsing datafusion-physical-expr-common v54.1.0 (baseline)
      Parsed [   0.023s] (baseline)
    Checking datafusion-physical-expr-common v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.300s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  50.056s] datafusion-physical-expr-common
    Building datafusion-physical-optimizer v54.1.0 (current)
       Built [  39.706s] (current)
     Parsing datafusion-physical-optimizer v54.1.0 (current)
      Parsed [   0.022s] (current)
    Building datafusion-physical-optimizer v54.1.0 (baseline)
       Built [  39.806s] (baseline)
     Parsing datafusion-physical-optimizer v54.1.0 (baseline)
      Parsed [   0.024s] (baseline)
    Checking datafusion-physical-optimizer v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.155s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  81.338s] datafusion-physical-optimizer
    Building datafusion-physical-plan v54.1.0 (current)
       Built [  36.757s] (current)
     Parsing datafusion-physical-plan v54.1.0 (current)
      Parsed [   0.149s] (current)
    Building datafusion-physical-plan v54.1.0 (baseline)
       Built [  37.108s] (baseline)
     Parsing datafusion-physical-plan v54.1.0 (baseline)
      Parsed [   0.149s] (baseline)
    Checking datafusion-physical-plan v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.980s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  76.418s] datafusion-physical-plan
    Building datafusion-proto v54.1.0 (current)
       Built [  61.390s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.019s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  61.127s] (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.360s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 124.192s] datafusion-proto
    Building datafusion-proto-models v54.1.0 (current)
       Built [  24.975s] (current)
     Parsing datafusion-proto-models v54.1.0 (current)
      Parsed [   0.136s] (current)
    Building datafusion-proto-models v54.1.0 (baseline)
       Built [  24.867s] (baseline)
     Parsing datafusion-proto-models v54.1.0 (baseline)
      Parsed [   0.138s] (baseline)
    Checking datafusion-proto-models v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   2.553s] 223 checks: 222 pass, 1 fail, 0 warn, 30 skip

--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.49.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field GlobalLimitExecNode.required_ordering in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:2246
  field GlobalLimitExecNode.required_ordering in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:2246
  field LocalLimitExecNode.required_ordering in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:2256
  field LocalLimitExecNode.required_ordering in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:2256

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

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

codecov-commenter commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.39344% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.04%. Comparing base (66c3840) to head (e6a8172).
⚠️ Report is 69 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-models/src/generated/pbjson.rs 0.00% 29 Missing ⚠️
datafusion/physical-plan/src/limit.rs 87.27% 4 Missing and 3 partials ⚠️
...ion/physical-plan/src/joins/symmetric_hash_join.rs 77.77% 4 Missing ⚠️
datafusion/physical-expr-common/src/sort_expr.rs 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24183      +/-   ##
==========================================
+ Coverage   80.86%   81.04%   +0.18%     
==========================================
  Files        1101     1106       +5     
  Lines      375446   382361    +6915     
  Branches   375446   382361    +6915     
==========================================
+ Hits       303592   309892    +6300     
- Misses      53761    54153     +392     
- Partials    18093    18316     +223     

☔ 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 optimizer Optimizer rules core Core DataFusion crate labels Aug 8, 2026
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 optimizer Optimizer rules 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.

Global/LocalLimitExec::required_ordering is not serialized, losing order-sensitivity of a pushed-down LIMIT

2 participants