Skip to content

Keep quoted empty trailing field with trailingDelimiter#616

Merged
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:trailing-delimiter-quoted-empty
Jun 22, 2026
Merged

Keep quoted empty trailing field with trailingDelimiter#616
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:trailing-delimiter-quoted-empty

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

addRecordValue drops the empty last field whenever the format's trailingDelimiter is enabled, checking only that the trimmed value is empty. A quoted empty field at the end of a record is a real value, not a trailing delimiter, so a,b,"" parsed with setTrailingDelimiter(true) came back as two values [a, b] instead of three [a, b, ""]. The unquoted case a,b, is a genuine trailing delimiter and still collapses to two fields. Fixed by only dropping the field when the token is unquoted; reusableToken.isQuoted is already tracked and used by handleNull.

Found while round-tripping records that contain an explicit empty quoted field.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your update.
Would you please update the Javadoc for "trailing delimiter" to explain the behavior. Especially contrasting with "trailing data".
TY!

@garydgregory garydgregory changed the title keep quoted empty trailing field with trailingDelimiter Keep quoted empty trailing field with trailingDelimiter Jun 21, 2026
@rootvector2

Copy link
Copy Markdown
Contributor Author

Done. Expanded the Javadoc on setTrailingDelimiter/getTrailingDelimiter to cover the write side (delimiter appended after the last value) and the read side (the empty field it produces is dropped, but a quoted empty trailing field "" is kept). Also noted it's unrelated to trailingData, which is about characters after a closing quote.

@garydgregory garydgregory merged commit 1dd04be into apache:master Jun 22, 2026
16 checks passed
@garydgregory

Copy link
Copy Markdown
Member

TY @rootvector2 , merged 🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants