Skip to content

Proto: migrate MemorySourceConfig to per-source try_to_proto / try_from_proto hooks - #24187

Merged
adriangb merged 4 commits into
apache:mainfrom
pydantic:claude/datafusion-issue-23518-c12d88
Aug 9, 2026
Merged

Proto: migrate MemorySourceConfig to per-source try_to_proto / try_from_proto hooks#24187
adriangb merged 4 commits into
apache:mainfrom
pydantic:claude/datafusion-issue-23518-c12d88

Conversation

@adriangb

@adriangb adriangb commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Continues the per-plan proto hook migration (#23494, pattern established in #23495 and #23683): each plan/source owns its wire logic via try_to_proto / try_from_proto hooks instead of the central downcast/match chains in datafusion-proto.

What changes are included in this PR?

  • DataSource::try_to_proto implemented for MemorySourceConfig and inherent MemorySourceConfig::try_from_proto added in datafusion/datasource/src/memory.rs (behind the proto feature). The record-batch IPC serde is pure Arrow and is inlined locally.
  • The MemoryScan decode arm in datafusion-proto now delegates to MemorySourceConfig::try_from_proto, and the central MemoryScan encode arm in try_from_data_source_exec is deleted — proof that the hook is the only path.
  • try_into_memory_scan_physical_plan becomes a deprecated shim delegating to the new hook; the now-unused serialize_record_batches / parse_record_batches helpers are deprecated.

The wire format is byte-for-byte identical: I verified locally that a memory scan plan (with sort information, fetch, and show_sizes=false) encodes to identical bytes before and after this change, and that bytes encoded by each version decode correctly with the other.

Are these changes tested?

Yes. Existing roundtrip tests (roundtrip_memory_source, roundtrip_memory_source_empty_projection) now exercise the hooks since the central arms are gone. A new test roundtrip_memory_source_sort_information_and_fetch covers sort_information, fetch, and show_sizes, asserting on the decoded MemorySourceConfig directly rather than only the display string.

Are there any user-facing changes?

No behavior changes. PhysicalPlanNodeExt::try_into_memory_scan_physical_plan, parse_record_batches, and serialize_record_batches are deprecated (still functional).

🤖 Generated with Claude Code

adriangb and others added 3 commits August 8, 2026 10:59
Implement DataSource::try_to_proto for MemorySourceConfig and the inherent
MemorySourceConfig::try_from_proto, moving the MemoryScan wire logic into the
crate that owns the type. The record-batch IPC serde is pure Arrow and is
inlined locally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Decode dispatches to MemorySourceConfig::try_from_proto; the central
MemoryScan encode arm in try_from_data_source_exec is deleted so the
DataSource::try_to_proto hook is the only path. The old decode helper
becomes a deprecated shim delegating to the new hook, and the now-unused
record-batch IPC helpers are deprecated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The display-string roundtrip does not cover every field, so the decoded
source is downcast and its fetch, show_sizes and sort_information are
asserted directly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource 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-datasource v54.1.0 (current)
       Built [  44.903s] (current)
     Parsing datafusion-datasource v54.1.0 (current)
      Parsed [   0.033s] (current)
    Building datafusion-datasource v54.1.0 (baseline)
       Built [  45.811s] (baseline)
     Parsing datafusion-datasource v54.1.0 (baseline)
      Parsed [   0.032s] (baseline)
    Checking datafusion-datasource v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.255s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  92.598s] datafusion-datasource
    Building datafusion-proto v54.1.0 (current)
       Built [  60.927s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.019s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  60.440s] (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.247s] 223 checks: 221 pass, 2 fail, 0 warn, 30 skip

--- failure function_marked_deprecated: function #[deprecated] added ---

Description:
A function is now #[deprecated]. Downstream crates will get a compiler warning when using this function.
        ref: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.49.0/src/lints/function_marked_deprecated.ron

Failed in:
  function datafusion_proto::physical_plan::from_proto::parse_record_batches in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/from_proto.rs:466
  function datafusion_proto::physical_plan::to_proto::serialize_record_batches in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/to_proto.rs:434

--- failure trait_method_marked_deprecated: trait method #[deprecated] added ---

Description:
A trait method is now #[deprecated]. Downstream crates will get a compiler warning when using this method.
        ref: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.49.0/src/lints/trait_method_marked_deprecated.ron

Failed in:
  method try_into_memory_scan_physical_plan in trait datafusion_proto::physical_plan::PhysicalPlanNodeExt in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/mod.rs:1034

     Summary semver requires new minor version: 0 major and 2 minor checks failed
    Finished [ 123.455s] datafusion-proto

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

adriangb commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@kumarUjjawal could I bother you for a review please 🙏🏻

@codecov-commenter

codecov-commenter commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.47826% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.04%. Comparing base (fc846dd) to head (2dabb54).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/datasource/src/memory.rs 75.00% 7 Missing and 13 partials ⚠️
datafusion/proto/src/physical_plan/mod.rs 10.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24187      +/-   ##
==========================================
- Coverage   81.05%   81.04%   -0.02%     
==========================================
  Files        1107     1106       -1     
  Lines      381574   382315     +741     
  Branches   381574   382315     +741     
==========================================
+ Hits       309281   309842     +561     
- Misses      54034    54159     +125     
- Partials    18259    18314      +55     

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

@kumarUjjawal kumarUjjawal 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.

Thanks @adriangb

Looks good, I left one non-blocking comments.

.expect("expected MemorySourceConfig");
assert_eq!(decoded_source.fetch(), Some(1));
assert!(!decoded_source.show_sizes());
assert_eq!(decoded_source.sort_information().len(), 1);

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.

Could this compare the decoded partitions, schema/projection, and complete ordering rather than only the ordering count?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 2dabb54

Review feedback: assert equality of partitions, schema, projection and the
complete sort information against the original source, not just counts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adriangb
adriangb added this pull request to the merge queue Aug 9, 2026
Merged via the queue into apache:main with commit abc5ce7 Aug 9, 2026
37 checks passed
@adriangb
adriangb deleted the claude/datafusion-issue-23518-c12d88 branch August 9, 2026 02:53
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 datasource Changes to the datasource crate proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proto: migrate MemorySourceConfig

3 participants