Repository navigation
GH-54535: [C++] Quote nulls in single-column CSV output so rows aren't written as empty lines - #54683
Open
CaptainAni187 wants to merge 1 commit into
Open
CaptainAni187 wants to merge 1 commit into
CaptainAni187 wants to merge 1 commit into
Conversation
… aren't written as empty lines
|
|
|
|
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.
Rationale for this change
With a one-column table, a null gets written as the empty null_string followed by the eol, so the row is just an empty line. The CSV reader skips empty lines by default, so every null row is lost on a write_csv / read_csv round trip.
What changes are included in this PR?
When the schema has a single column and null_string is empty, the writer now writes nulls as
""instead of nothing. A quoted empty value already reads back as null for non-string columns (quoted_strings_can_be_null), and the row is kept for string columns too.It only kicks in for that one case. A custom null_string, tables with more than one column, and QuotingStyle::None keep the old output. I left None alone since it promises no quotes at all.... happy to change that if you'd rather it also writes
"".Also added a note about this on WriteOptions::null_string.
Are these changes tested?
Yes. Updated the existing SingleColumnWriteCSVTest case (it was asserting the empty line), added cases for Needed, AllValid, None, a custom null_string, a string column and two columns, plus a round trip test that writes a one-column table with nulls and reads it back with default options.
Are there any user-facing changes?
Yes, single-column CSV output with nulls changes from an empty line to
""(with the default empty null_string).Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
The fix, tests and this description were drafted with Claude Code.
PR code and description written by:
Reviewed before submission by:
read_csvskips by default, so null rows are lost on a round trip #54535