Skip to content

fix(proto): destructure JSON source and sink serde hooks - #24945

Open
buraksenn wants to merge 2 commits into
apache:mainfrom
buraksenn:24621-json-source-sink-proto-destructure
Open

fix(proto): destructure JSON source and sink serde hooks#24945
buraksenn wants to merge 2 commits into
apache:mainfrom
buraksenn:24621-json-source-sink-proto-destructure

Conversation

@buraksenn

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Protobuf hooks that access fields individually can silently omit newly added
state. For JSON sinks, this caused an explicitly configured compression level
to revert to the default after a physical-plan protobuf roundtrip.

Exhaustive destructuring makes newly added source, sink, and wire fields compile
errors until their serialization behavior is explicitly considered.

What changes are included in this PR?

  • Exhaustively destructure JsonSource and JsonSink in their encoders.
  • Exhaustively destructure their protobuf nodes in the decoders.
  • Keep the active JsonSink hook exhaustive while centralizing field mapping in
    its public TryFrom<&JsonSink> conversion.
  • Add compression_level to the JsonWriterOptions protobuf message and
    preserve it in both conversion directions.
  • Strengthen the JSON sink roundtrip test to inspect non-default sink options,
    file configuration, and sort order directly.

The protobuf change is additive and backward compatible.

Are these changes tested?

Yes. The focused JSON source and sink roundtrip tests pass:

cargo test -p datafusion-proto --test proto_integration roundtrip_json

Are there any user-facing changes?

Physical plans containing JSON sinks now preserve an explicitly configured
compression level across protobuf roundtrips. Older payloads without the new
field continue to decode with no explicit compression level.

There are no breaking API changes.

@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource crate labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 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-json v55.0.0 (current)
       Built [  43.940s] (current)
     Parsing datafusion-datasource-json v55.0.0 (current)
      Parsed [   0.013s] (current)
    Building datafusion-datasource-json v55.0.0 (baseline)
       Built [  42.757s] (baseline)
     Parsing datafusion-datasource-json v55.0.0 (baseline)
      Parsed [   0.013s] (baseline)
    Checking datafusion-datasource-json v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.103s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  88.175s] datafusion-datasource-json
    Building datafusion-proto v55.0.0 (current)
       Built [  52.731s] (current)
     Parsing datafusion-proto v55.0.0 (current)
      Parsed [   0.017s] (current)
    Building datafusion-proto v55.0.0 (baseline)
       Built [  53.028s] (baseline)
     Parsing datafusion-proto v55.0.0 (baseline)
      Parsed [   0.018s] (baseline)
    Checking datafusion-proto v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.134s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 107.293s] datafusion-proto
    Building datafusion-proto-common v55.0.0 (current)
       Built [  21.613s] (current)
     Parsing datafusion-proto-common v55.0.0 (current)
      Parsed [   0.045s] (current)
    Building datafusion-proto-common v55.0.0 (baseline)
       Built [  21.685s] (baseline)
     Parsing datafusion-proto-common v55.0.0 (baseline)
      Parsed [   0.046s] (baseline)
    Checking datafusion-proto-common v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   1.339s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip

--- failure constructible_struct_adds_field: struct exhaustively constructible through public API adds field ---

Description:
A pub struct that could be exhaustively constructed with a literal using only public API has a new pub field, breaking existing exhaustive literals.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field JsonWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:587
  field JsonWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:587
  field JsonWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:587

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  45.720s] datafusion-proto-common
    Building datafusion-proto-models v55.0.0 (current)
       Built [  24.549s] (current)
     Parsing datafusion-proto-models v55.0.0 (current)
      Parsed [   0.124s] (current)
    Building datafusion-proto-models v55.0.0 (baseline)
       Built [  24.381s] (baseline)
     Parsing datafusion-proto-models v55.0.0 (baseline)
      Parsed [   0.125s] (baseline)
    Checking datafusion-proto-models v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   2.011s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip

--- failure constructible_struct_adds_field: struct exhaustively constructible through public API adds field ---

Description:
A pub struct that could be exhaustively constructed with a literal using only public API has a new pub field, breaking existing exhaustive literals.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field JsonWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:587
  field JsonWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:587

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

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.79310% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.58%. Comparing base (9ef3d47) to head (59d0f47).
⚠️ Report is 64 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-common/src/generated/pbjson.rs 0.00% 13 Missing ⚠️
datafusion/datasource-json/src/file_format.rs 66.66% 2 Missing and 5 partials ⚠️
datafusion/datasource-json/src/source.rs 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24945      +/-   ##
==========================================
+ Coverage   81.52%   81.58%   +0.06%     
==========================================
  Files        1123     1123              
  Lines      405970   410945    +4975     
  Branches   405970   410945    +4975     
==========================================
+ Hits       330983   335287    +4304     
- Misses      55626    55912     +286     
- Partials    19361    19746     +385     

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

Destructure proto hooks for the JSON source and sink

2 participants