Skip to content

Conversation

@xanderbailey
Copy link

@xanderbailey xanderbailey commented Dec 5, 2025

Which issue does this PR close?

We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.

Rationale for this change

Spark's csv writer can do this and it would be nice to have feature parity in projects like datafusion.
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.

What changes are included in this PR?

Adds two new options for ignore_leading_whitespace and ignore_trailing_whitespace to csv writer.
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.

Are these changes tested?

Yes
We typically require tests for all PRs in order to:

  1. Prevent the code from being accidentally broken by subsequent changes
  2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?

Are there any user-facing changes?

If there are user-facing changes then we may require documentation to be updated before approving the PR.

If there are any breaking changes to public APIs, please call them out.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Dec 5, 2025
Comment on lines +170 to +175
if self.ignore_leading_whitespace {
trimmed = trimmed.trim_start();
}
if self.ignore_trailing_whitespace {
trimmed = trimmed.trim_end();
}
Copy link
Author

Choose a reason for hiding this comment

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

Very open to suggestions if this is the right way to go about this. It looks like the other options are passed into FormatOptions but that's used much more widely than just the CSV reader...

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.

Add spark like ignoreLeadingWhiteSpace and ignoreTrailingWhiteSpace options to the csv writer

1 participant