Skip to content

Proto: migrate file sink serialization#23781

Draft
Phoenix500526 wants to merge 5 commits into
apache:mainfrom
Phoenix500526:issue/23519
Draft

Proto: migrate file sink serialization#23781
Phoenix500526 wants to merge 5 commits into
apache:mainfrom
Phoenix500526:issue/23519

Conversation

@Phoenix500526

Copy link
Copy Markdown
Contributor

This is a stacked PR based on #23752. Only the commits on top of #23752 are part of this review.

Which issue does this PR close?

Rationale for this change

#23752 adds the DataSink::try_to_proto hook and moves the shared
FileSinkConfig protobuf conversion into datafusion-datasource.

This PR uses that foundation to move CSV, JSON, and Parquet sink
serialization out of the central datafusion-proto downcast chain.
Each concrete sink now owns its format-specific protobuf encoding and
decoding logic.

What changes are included in this PR?

  • Implement DataSink::try_to_proto for CsvSink, JsonSink, and
    ParquetSink.
  • Add inherent try_from_proto methods to reconstruct each sink's
    DataSinkExec.
  • Repoint the physical-plan decode arms to the sink-owned decoders.
  • Add feature-gated protobuf dependencies to the three format crates.
  • Remove the active central DataSinkExec serialization dispatch after
    migrating its final built-in sink.
  • Retain the old serialization helpers as deprecated compatibility
    delegates.
  • Let sinks without a built-in protobuf representation fall through to
    the physical extension codec.
  • Preserve the existing protobuf wire representation.

The migrations are split into one commit per sink.

Are these changes tested?

Yes. Existing sink round-trip tests cover the protobuf representation.

The following checks passed:

  • Focused CSV, JSON, and Parquet sink round-trip tests.
  • All datafusion-proto integration tests.
  • cargo check -p datafusion-proto --no-default-features.
  • cargo fmt --all.
  • cargo clippy --all-targets --all-features -- -D warnings.
  • The required extended workspace test suite, including all 495 SQL
    logic test files.

Are there any user-facing changes?

No functional or wire-format changes are intended.

The old compatibility helpers remain available but are deprecated.

DataSinkExec needs a generic way to delegate protobuf encoding to its
wrapped sink. The new hook keeps sink-specific wire logic out of the
central serializer while retaining the fallback for unmigrated sinks.

Add focused coverage for child and sort-order encoding and verify that
existing file sinks continue to use the compatibility path.

Refs apache#23498
FileSinkConfig is owned by datafusion-datasource, but its protobuf
conversion lived in the central proto crate. Co-locating it lets sink
implementations reuse the wire logic without depending on
datafusion-proto.

Keep existing TryFromProto implementations as compatibility delegates
and verify both APIs produce the same protobuf data.

CLOSES apache#23498
CsvSink serialization still depended on central downcasts in
datafusion-proto. Moving encode and decode ownership into the CSV sink
exercises the DataSink hook and keeps format-specific wire logic with
the concrete type.

Retain the old decode helper as a deprecated compatibility shim.

Refs apache#23519
JsonSink serialization still depended on central downcasts in
datafusion-proto. Moving encode and decode ownership into the JSON sink
exercises the DataSink hook and keeps format-specific wire logic with
the concrete type.

Retain the old decode helper as a deprecated compatibility shim.

Refs apache#23519
ParquetSink serialization still depended on the final concrete sink
downcast in datafusion-proto. Moving encode and decode ownership into
the Parquet sink completes the DataSink migration and keeps
format-specific wire logic with the concrete type.

Remove the now-unused central dispatch path while retaining its public
helpers as deprecated compatibility shims.

Refs apache#23519

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
@Phoenix500526
Phoenix500526 marked this pull request as draft July 21, 2026 23:59
@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource crate labels Jul 22, 2026
@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-datasource v54.1.0 (current)
       Built [  50.771s] (current)
     Parsing datafusion-datasource v54.1.0 (current)
      Parsed [   0.033s] (current)
    Building datafusion-datasource v54.1.0 (baseline)
       Built [  40.822s] (baseline)
     Parsing datafusion-datasource v54.1.0 (baseline)
      Parsed [   0.031s] (baseline)
    Checking datafusion-datasource 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 [  93.455s] datafusion-datasource
    Building datafusion-datasource-csv v54.1.0 (current)
       Built [  43.295s] (current)
     Parsing datafusion-datasource-csv v54.1.0 (current)
      Parsed [   0.012s] (current)
    Building datafusion-datasource-csv v54.1.0 (baseline)
       Built [  38.699s] (baseline)
     Parsing datafusion-datasource-csv v54.1.0 (baseline)
      Parsed [   0.012s] (baseline)
    Checking datafusion-datasource-csv v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.101s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  83.111s] datafusion-datasource-csv
    Building datafusion-datasource-json v54.1.0 (current)
       Built [  42.470s] (current)
     Parsing datafusion-datasource-json v54.1.0 (current)
      Parsed [   0.013s] (current)
    Building datafusion-datasource-json v54.1.0 (baseline)
       Built [  38.622s] (baseline)
     Parsing datafusion-datasource-json v54.1.0 (baseline)
      Parsed [   0.013s] (baseline)
    Checking datafusion-datasource-json v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.091s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  82.173s] datafusion-datasource-json
    Building datafusion-datasource-parquet v54.1.0 (current)
       Built [  48.013s] (current)
     Parsing datafusion-datasource-parquet v54.1.0 (current)
      Parsed [   0.032s] (current)
    Building datafusion-datasource-parquet v54.1.0 (baseline)
       Built [  44.141s] (baseline)
     Parsing datafusion-datasource-parquet v54.1.0 (baseline)
      Parsed [   0.033s] (baseline)
    Checking datafusion-datasource-parquet v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.162s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  93.465s] datafusion-datasource-parquet
    Building datafusion-proto v54.1.0 (current)
       Built [  60.503s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.018s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  61.568s] (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.246s] 223 checks: 222 pass, 1 fail, 0 warn, 30 skip

--- 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_json_sink_physical_plan in trait datafusion_proto::physical_plan::PhysicalPlanNodeExt in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/mod.rs:722
  method try_into_csv_sink_physical_plan in trait datafusion_proto::physical_plan::PhysicalPlanNodeExt in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/mod.rs:722
  method try_into_parquet_sink_physical_plan in trait datafusion_proto::physical_plan::PhysicalPlanNodeExt in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/mod.rs:722
  method try_from_data_sink_exec in trait datafusion_proto::physical_plan::PhysicalPlanNodeExt in /home/runner/work/datafusion/datafusion/datafusion/proto/src/physical_plan/mod.rs:722

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

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.13317% with 144 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.68%. Comparing base (050046a) to head (e4d4161).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...atafusion/datasource/src/file_sink_config/proto.rs 69.18% 23 Missing and 26 partials ⚠️
datafusion/proto/src/physical_plan/mod.rs 8.10% 34 Missing ⚠️
datafusion/datasource-csv/src/file_format.rs 72.88% 9 Missing and 7 partials ⚠️
datafusion/datasource-json/src/file_format.rs 72.88% 9 Missing and 7 partials ⚠️
datafusion/datasource-parquet/src/sink.rs 72.88% 9 Missing and 7 partials ⚠️
datafusion/datasource/src/sink.rs 65.78% 10 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23781      +/-   ##
==========================================
- Coverage   80.71%   80.68%   -0.04%     
==========================================
  Files        1089     1090       +1     
  Lines      368750   368965     +215     
  Branches   368750   368965     +215     
==========================================
+ Hits       297631   297692      +61     
- Misses      53375    53517     +142     
- Partials    17744    17756      +12     

☔ 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 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 the file sinks (CsvSink, JsonSink, ParquetSink)

2 participants