Skip to content

fix(proto): preserve CSV/JSON scan options on roundtrip - #24233

Open
buraksenn wants to merge 4 commits into
apache:mainfrom
buraksenn:24180-preserve-csv-json-scan-options
Open

fix(proto): preserve CSV/JSON scan options on roundtrip#24233
buraksenn wants to merge 4 commits into
apache:mainfrom
buraksenn:24180-preserve-csv-json-scan-options

Conversation

@buraksenn

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Physical-plan protobuf serialization does not preserve several CSV and JSON scan options. Custom CSV terminators, JSON newline-delimited mode, and file compression therefore revert to their defaults after a roundtrip, which can cause the
decoded plan to read the file incorrectly.

What changes are included in this PR?

  • Add terminator to CsvScanExecNode.
  • Add newline_delimited to JsonScanExecNode.
  • Add file_compression_type to the shared FileScanExecConf.
  • Serialize and restore these options in CSV and JSON scans.

Are these changes tested?

Yes. Extended the CSV and JSON physical-plan roundtrip tests to cover custom terminators, non-newline-delimited JSON, compression, and backward-compatible defaults.

Are there any user-facing changes?

CSV and JSON scans now preserve their format and compression options across protobuf roundtrips. The protobuf changes are additive and backward compatible. JsonSource also gains an is_newline_delimited getter.

@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource crate labels Aug 10, 2026
…json-scan-options

# Conflicts:
#	datafusion/proto/tests/cases/roundtrip_physical_plan.rs
@github-actions

github-actions Bot commented Aug 10, 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 [  42.603s] (current)
     Parsing datafusion-datasource v54.1.0 (current)
      Parsed [   0.034s] (current)
    Building datafusion-datasource v54.1.0 (baseline)
       Built [  42.041s] (baseline)
     Parsing datafusion-datasource v54.1.0 (baseline)
      Parsed [   0.034s] (baseline)
    Checking datafusion-datasource v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.389s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  86.747s] datafusion-datasource
    Building datafusion-datasource-csv v54.1.0 (current)
       Built [  42.568s] (current)
     Parsing datafusion-datasource-csv v54.1.0 (current)
      Parsed [   0.012s] (current)
    Building datafusion-datasource-csv v54.1.0 (baseline)
       Built [  42.698s] (baseline)
     Parsing datafusion-datasource-csv v54.1.0 (baseline)
      Parsed [   0.013s] (baseline)
    Checking datafusion-datasource-csv v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.137s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  86.732s] datafusion-datasource-csv
    Building datafusion-datasource-json v54.1.0 (current)
       Built [  42.740s] (current)
     Parsing datafusion-datasource-json v54.1.0 (current)
      Parsed [   0.013s] (current)
    Building datafusion-datasource-json v54.1.0 (baseline)
       Built [  42.884s] (baseline)
     Parsing datafusion-datasource-json v54.1.0 (baseline)
      Parsed [   0.014s] (baseline)
    Checking datafusion-datasource-json v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.119s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  87.006s] datafusion-datasource-json
    Building datafusion-proto v54.1.0 (current)
       Built [  60.655s] (current)
     Parsing datafusion-proto v54.1.0 (current)
      Parsed [   0.019s] (current)
    Building datafusion-proto v54.1.0 (baseline)
       Built [  60.779s] (baseline)
     Parsing datafusion-proto v54.1.0 (baseline)
      Parsed [   0.021s] (baseline)
    Checking datafusion-proto v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.332s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 123.275s] datafusion-proto
    Building datafusion-proto-models v54.1.0 (current)
       Built [  24.421s] (current)
     Parsing datafusion-proto-models v54.1.0 (current)
      Parsed [   0.136s] (current)
    Building datafusion-proto-models v54.1.0 (baseline)
       Built [  24.530s] (baseline)
     Parsing datafusion-proto-models v54.1.0 (baseline)
      Parsed [   0.136s] (baseline)
    Checking datafusion-proto-models v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   2.462s] 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 JsonScanExecNode.newline_delimited in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1993
  field JsonScanExecNode.newline_delimited in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1993
  field FileScanExecConf.file_compression_type in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1939
  field FileScanExecConf.file_compression_type in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1939
  field CsvScanExecNode.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1968
  field CsvScanExecNode.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1968

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

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

codecov-commenter commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.45545% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.98%. Comparing base (d5bd10d) to head (129d5b4).

Files with missing lines Patch % Lines
datafusion/proto-models/src/generated/pbjson.rs 0.00% 41 Missing ⚠️
datafusion/datasource-csv/src/source.rs 75.00% 0 Missing and 3 partials ⚠️
datafusion/proto/src/physical_plan/mod.rs 88.88% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24233      +/-   ##
==========================================
- Coverage   80.98%   80.98%   -0.01%     
==========================================
  Files        1106     1106              
  Lines      383495   383588      +93     
  Branches   383495   383588      +93     
==========================================
+ Hits       310590   310635      +45     
- Misses      54572    54612      +40     
- Partials    18333    18341       +8     

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

Physical plan proto silently drops CSV/JSON scan options (newline_delimited, terminator, compression)

2 participants