Skip to content

Conversation

@xanderbailey
Copy link
Contributor

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 quoteAll setting.

Rationale for this change

What changes are included in this PR?

Expose QuoteStyle in the WriterBuilder

Are these changes tested?

Yes with examples and unit tests.

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Dec 16, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
       )

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @xanderbailey

@alamb alamb merged commit 9aca68b into apache:main Dec 17, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants