Merged
Conversation
alamb
reviewed
Dec 16, 2025
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thanks @xanderbailey - this is looking good
| pub use self::reader::Reader; | ||
| pub use self::reader::ReaderBuilder; | ||
| pub use self::reader::infer_schema_from_files; | ||
| pub use self::writer::QuoteStyle; |
Contributor
There was a problem hiding this comment.
This is publicly exporting something from the csv crate (which I think is good): https://docs.rs/csv/latest/csv/enum.QuoteStyle.html
| //! | ||
| //! ## Available Quoting Styles | ||
| //! | ||
| //! - `QuoteStyle::Necessary` (default): Only quotes fields when necessary (e.g., when they |
Contributor
There was a problem hiding this comment.
I think this is redundant with the existing documentation on QuoteStyle -- the link above to QuoteStyle is probably fine
| .unwrap(); | ||
|
|
||
| // Test with QuoteStyle::Necessary (default) | ||
| let mut buf = Vec::new(); |
Contributor
There was a problem hiding this comment.
Can you please reduce some of this boiler plate code? It is obscuring what is going on in the tests -- maybe a helper so these tests end up looking something like this:
assert_eq!(
"text,number,float\nhello,1,1.1\nworld,2,2.2\n\"comma,value\",3,3.3\n\"quote\"\"test\",4,4.4\n",
write_quote_style(batch, QuoteStyle::Necessary
)2fcd584 to
f1655ac
Compare
Jefffrey
pushed a commit
to Jefffrey/datafusion
that referenced
this pull request
Apr 24, 2026
## Which issue does this PR close? - Closes apache#10669 Related arrow-rs PRs apache/arrow-rs#8960 and apache/arrow-rs#9004 ## Rationale for this change The CSV writer was missing support for `quote_style`, `ignore_leading_whitespace`, and `ignore_trailing_whitespace` options that are available on the underlying arrow `WriterBuilder`. This meant users couldn't control quoting behaviour or whitespace trimming when writing CSV files. ## What changes are included in this PR? Adds three new CSV writer options wired through the full stack: - `quote_style` — controls when fields are quoted (`Always`, `Necessary`, `NonNumeric`, `Never`). Modelled as a protobuf enum (`CsvQuoteStyle`). - `ignore_leading_whitespace` — trims leading whitespace from string values on write. - `ignore_trailing_whitespace` — trims trailing whitespace from string values on write. ## Are these changes tested? Yes — sqllogictest coverage added in `csv_files.slt` ## Are there any user-facing changes? Three new `format.*` options available in COPY TO and CREATE EXTERNAL TABLE for CSV: - `format.quote_style` (string: `Always`, `Necessary`, `NonNumeric`, `Never`) - `format.ignore_leading_whitespace` (boolean) - `format.ignore_trailing_whitespace` (boolean)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Following on from #8960, we are now exposing the quote style as a part of the csv writer options which allows users to quote columns similar to Spark's
quoteAllsetting.Rationale for this change
What changes are included in this PR?
Expose
QuoteStylein theWriterBuilderAre these changes tested?
Yes with examples and unit tests.
Are there any user-facing changes?