Skip to content

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
apache:mainfrom
CaptainAni187:GH-54535-csv-single-column-null
Open

CaptainAni187 wants to merge 1 commit into
apache:mainfrom
CaptainAni187:GH-54535-csv-single-column-null

Conversation

@CaptainAni187

Copy link
Copy Markdown
Contributor

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:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions github-actions Bot added the awaiting review Awaiting review label Oct 20, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54535 has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54535 has no components, please add labels for components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant