Skip to content

GH-51368: [C++] Fix silent LF drop when quoted CRLF straddles CSV blo… - #54059

Open
AdityRajGupta wants to merge 1 commit into
apache:mainfrom
AdityRajGupta:gh-51368-csv-crlf-fix
Open

AdityRajGupta wants to merge 1 commit into
apache:mainfrom
AdityRajGupta:gh-51368-csv-crlf-fix

Conversation

@AdityRajGupta

@AdityRajGupta AdityRajGupta commented Oct 17, 2026 •

Copy link
Copy Markdown

Rationale for this change

With newlines_in_values=true, a \r\n inside a quoted field can be split across two read blocks. When \r is the last byte of one block and \n is the first byte of the next, the reader drops the \n and corrupts the field value. See #51368.

What changes are included in this PR?

CSVBufferIterator now keeps a trailing \r and adds it to the next buffer instead of dropping the following \n. This keeps CRLF together across block boundaries. A pending \r at EOF is also preserved.

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

This PR contains a "Critical Fix": it fixes (b) a bug that caused incorrect data to be produced.

Was AI used for this PR?

Yes AI was used for assistance during the development process mainly in understanding the issue.

gh51368-new-tests gh51368-full-suite

Added regression tests for the serial, async, and streaming readers.
These particular test cases were failing before the fix. All 3 now pass with the fix.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI

Copilot AI balanced review requested due to automatic review settings October 17, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

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

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.

2 participants