Skip to content

fix(proto): preserve CSV sink writer options - #25058

Open
buraksenn wants to merge 1 commit into
apache:mainfrom
buraksenn:24623-csv-sink-proto-destructure-v2
Open

fix(proto): preserve CSV sink writer options#25058
buraksenn wants to merge 1 commit into
apache:mainfrom
buraksenn:24623-csv-sink-proto-destructure-v2

Conversation

@buraksenn

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The CSV sink protobuf hooks accessed state indirectly, allowing new fields to be omitted silently. Auditing the writer options found that compression level, timezone-aware timestamp format, and line terminator were not represented on the wire, so those settings changed after a physical-plan round trip.

What changes are included in this PR?

  • Exhaustively destructure CsvSink, CsvSinkExecNode, and the nested CSV sink/writer option messages.
  • Add protobuf fields for compression level, timezone-aware timestamp format, and line terminator.
  • Preserve None for optional format strings and reject malformed line terminators.
  • Regenerate the protobuf models.

The protobuf changes are additive and backward compatible.

What is the testing strategy for this PR?

Expanded the CSV sink round-trip test to cover every writer option, optional defaults, and malformed line terminators.

Validated with:

  • cargo test -p datafusion-proto --test proto_integration roundtrip_csv_sink
  • cargo clippy -p datafusion-datasource-csv -p datafusion-proto-common -p datafusion-proto --all-features --tests -- -D warnings
  • cargo fmt --all --check

Are there any user-facing changes?

CSV sinks now retain compression level, timezone-aware timestamp formatting, and line terminators across protobuf plan round trips. Invalid wire terminators return an error. The protobuf additions are backward compatible.

@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource crate labels Sep 8, 2026
@buraksenn
buraksenn marked this pull request as draft September 8, 2026 09:10
@github-actions

github-actions Bot commented Sep 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-csv v55.0.0 (current)
       Built [  45.543s] (current)
     Parsing datafusion-datasource-csv v55.0.0 (current)
      Parsed [   0.012s] (current)
    Building datafusion-datasource-csv v55.0.0 (baseline)
       Built [  44.724s] (baseline)
     Parsing datafusion-datasource-csv v55.0.0 (baseline)
      Parsed [   0.012s] (baseline)
    Checking datafusion-datasource-csv 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 [  92.332s] datafusion-datasource-csv
    Building datafusion-proto v55.0.0 (current)
       Built [  54.887s] (current)
     Parsing datafusion-proto v55.0.0 (current)
      Parsed [   0.018s] (current)
    Building datafusion-proto v55.0.0 (baseline)
       Built [  54.897s] (baseline)
     Parsing datafusion-proto v55.0.0 (baseline)
      Parsed [   0.019s] (baseline)
    Checking datafusion-proto v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   0.111s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 111.321s] datafusion-proto
    Building datafusion-proto-common v55.0.0 (current)
       Built [  22.167s] (current)
     Parsing datafusion-proto-common v55.0.0 (current)
      Parsed [   0.046s] (current)
    Building datafusion-proto-common v55.0.0 (baseline)
       Built [  22.377s] (baseline)
     Parsing datafusion-proto-common v55.0.0 (baseline)
      Parsed [   0.048s] (baseline)
    Checking datafusion-proto-common v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   1.119s] 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 CsvWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:635
  field CsvWriterOptions.timestamp_tz_format in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:638
  field CsvWriterOptions.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:641
  field CsvWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:635
  field CsvWriterOptions.timestamp_tz_format in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:638
  field CsvWriterOptions.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:641
  field CsvWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:635
  field CsvWriterOptions.timestamp_tz_format in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:638
  field CsvWriterOptions.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-common/src/generated/prost.rs:641

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  46.814s] datafusion-proto-common
    Building datafusion-proto-models v55.0.0 (current)
       Built [  25.293s] (current)
     Parsing datafusion-proto-models v55.0.0 (current)
      Parsed [   0.131s] (current)
    Building datafusion-proto-models v55.0.0 (baseline)
       Built [  25.150s] (baseline)
     Parsing datafusion-proto-models v55.0.0 (baseline)
      Parsed [   0.128s] (baseline)
    Checking datafusion-proto-models v55.0.0 -> v55.0.0 (no change; assume patch)
     Checked [   1.746s] 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 CsvWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:635
  field CsvWriterOptions.timestamp_tz_format in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:638
  field CsvWriterOptions.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:641
  field CsvWriterOptions.compression_level in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:635
  field CsvWriterOptions.timestamp_tz_format in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:638
  field CsvWriterOptions.terminator in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/datafusion_proto_common.rs:641

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

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.81720% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.74%. Comparing base (92746a9) to head (ad7fb62).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-common/src/generated/pbjson.rs 0.00% 40 Missing ⚠️
datafusion/proto-common/src/from_proto/mod.rs 87.50% 11 Missing ⚠️
datafusion/datasource-csv/src/file_format.rs 66.66% 2 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25058      +/-   ##
==========================================
- Coverage   81.74%   81.74%   -0.01%     
==========================================
  Files        1128     1128              
  Lines      416645   416738      +93     
  Branches   416645   416738      +93     
==========================================
+ Hits       340580   340646      +66     
- Misses      55998    56024      +26     
- Partials    20067    20068       +1     

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

@buraksenn
buraksenn marked this pull request as ready for review September 8, 2026 15:14
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 CSV sink

2 participants