Skip to content

GH-34577 [Python] Expose eol and null_string csv WriteOptions - #46976

Open
MartinNowak wants to merge 1 commit into
apache:mainfrom
MartinNowak:fix-34577-expand-csv-write-options
Open

GH-34577 [Python] Expose eol and null_string csv WriteOptions#46976
MartinNowak wants to merge 1 commit into
apache:mainfrom
MartinNowak:fix-34577-expand-csv-write-options

Conversation

@MartinNowak

@MartinNowakMartinNowak commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

Rationale for this change

Expose remaining csv write options to pyarrow.

What changes are included in this PR?

Adding eol and null_string to csv.WriteOptions.

Are these changes tested?

Yes, testing of setters included.

Are there any user-facing changes?

@github-actions

Copy link
Copy Markdown

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

@AlenkaF

Copy link
Copy Markdown
Member

Thank you for submitting a PR!
There are some fixes needed for the CI to pass:

  • Linter error:
    python/pyarrow/tests/test_csv.py:363:89: E501 line too long (119 > 88 characters)
  • Python builds error:
    pyarrow/_csv.pyx:1431:34: Object of type 'CCSVWriteOptions &' has no attribute 'eol'
    -> CCSVWriteOptions will need to be updated in the libarrow.pxd

@MartinNowak
MartinNowakforce-pushed the fix-34577-expand-csv-write-options branch 2 times, most recently from 34366df to dd3ae8fCompareAugust 4, 2025 11:45
@MartinNowakMartinNowak changed the title GH-34577 [Python] Expose eol and null_value csv WriteOptionsGH-34577 [Python] Expose eol and null_string csv WriteOptionsAug 4, 2025
@MartinNowak
MartinNowakforce-pushed the fix-34577-expand-csv-write-options branch 2 times, most recently from 58c1bd0 to 6907545CompareAugust 7, 2025 14:37
@AlenkaF

Copy link
Copy Markdown
Member

The failures are connected, see:

______________________________test_write_options______________________________deftest_write_options():
cls=WriteOptionsopts=cls()
>check_options_class(
cls, include_header=[True, False], delimiter=[',', '\t', '|'],
eol=['\n', '\r\n'], null_string=['', 'NA'],
quoting_style=['needed', 'none', 'all_valid'])
opt/conda/envs/arrow/lib/python3.9/site-packages/pyarrow/tests/test_csv.py:362: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ opt/conda/envs/arrow/lib/python3.9/site-packages/pyarrow/tests/test_csv.py:111: incheck_options_classopts=cls(**non_defaults)
pyarrow/_csv.pyx:1388: inpyarrow._csv.WriteOptions.__init__
???
pyarrow/_csv.pyx:1446: inpyarrow._csv.WriteOptions.null_string.__set__
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ???
ETypeError: expectedbytes, NoneTypefound

@MartinNowak
MartinNowakforce-pushed the fix-34577-expand-csv-write-options branch from 6907545 to f95d305CompareAugust 15, 2025 06:58
@github-actionsgithub-actionsBot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 15, 2025

@MartinNowakMartinNowak left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Was on vacation and it took a bit longer to get back to this. Hope it runs through now 🤞 @AlenkaF.

Comment threadpython/pyarrow/_csv.pyx Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

???
E TypeError: expected bytes, NoneType found

It found this glorious typo 🤦. Only have semi-working syntax highlighting and didn't have enough time to figure out how to run the tests locally :/.

@AlenkaF

Copy link
Copy Markdown
Member

The tests are passing 👍
But the docstrings need an update:

pyarrow._csv.WriteOptions->pyarrow._csv.WriteOptions(include_header=None, *, batch_size=None, delimiter=None, eol=None, null_string=None, quoting_style=None)
PR01: Parameters {'delimiter', 'null_string', 'eol', 'batch_size', 'quoting_style'} notdocumentedPR04: Parameter"")" hasnotype

@MartinNowak
MartinNowakforce-pushed the fix-34577-expand-csv-write-options branch from f95d305 to 08fa441CompareAugust 21, 2025 09:14
Comment threadpython/pyarrow/_csv.pyx Outdated

@MartinNowakMartinNowakAug 21, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The tests are passing 👍
But the docstrings need an update:

Needed to escape the backslash to render in final doc rather than to break the doc comment.

@MartinNowak

Copy link
Copy Markdown
ContributorAuthor

The macOS failures seem to be apache/orc#2357 and were not present previously f95d305@AlenkaF.

@raulcdraulcd 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.

The macOS failures are fixed on main, can you rebase so they are fixed on CI, please?

@raulcd

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g python

@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Aug 26, 2025
@github-actions

Copy link
Copy Markdown

Revision: 08fa4412afc3bbb2e1599a4ad9557fe8a0f3a075

Submitted crossbow builds: ursacomputing/crossbow @ actions-c05e9be928

TaskStatus
example-python-minimal-build-fedora-condaGitHub Actions
example-python-minimal-build-ubuntu-venvGitHub Actions
test-conda-python-3.10GitHub Actions
test-conda-python-3.10-hdfs-2.9.2GitHub Actions
test-conda-python-3.10-hdfs-3.2.1GitHub Actions
test-conda-python-3.10-pandas-latest-numpy-latestGitHub Actions
test-conda-python-3.11GitHub Actions
test-conda-python-3.11-dask-latestGitHub Actions
test-conda-python-3.11-dask-upstream_develGitHub Actions
test-conda-python-3.11-hypothesisGitHub Actions
test-conda-python-3.11-pandas-latest-numpy-1.26GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-latestGitHub Actions
test-conda-python-3.11-pandas-nightly-numpy-nightlyGitHub Actions
test-conda-python-3.11-pandas-upstream_devel-numpy-nightlyGitHub Actions
test-conda-python-3.11-spark-masterGitHub Actions
test-conda-python-3.12GitHub Actions
test-conda-python-3.12-cpython-debugGitHub Actions
test-conda-python-3.13GitHub Actions
test-conda-python-3.9GitHub Actions
test-conda-python-3.9-pandas-1.1.3-numpy-1.19.5GitHub Actions
test-conda-python-emscriptenGitHub Actions
test-cuda-python-ubuntu-22.04-cuda-11.7.1GitHub Actions
test-debian-12-python-3-amd64GitHub Actions
test-debian-12-python-3-i386GitHub Actions
test-fedora-42-python-3GitHub Actions
test-ubuntu-22.04-python-3GitHub Actions
test-ubuntu-22.04-python-313-freethreadingGitHub Actions
test-ubuntu-24.04-python-3GitHub Actions

@MartinNowak
MartinNowakforce-pushed the fix-34577-expand-csv-write-options branch from 08fa441 to 220c3fcCompareAugust 27, 2025 06:09
@github-actionsgithub-actionsBot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Aug 27, 2025

@raulcdraulcd 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.

Thanks for the PR, sorry I took a little to review.
This seems to only be testing that the options class can be generated but is not indeed testing the options, on test_csv.py we have other tests that indeed test the options like:

deftest_write_read_round_trip():

or
deftest_write_quoting_style():

Can we test the options are indeed working as expected when writing the CSV?

@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Aug 27, 2025
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Unfortunately, this pull request has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this PR will be closed in 14 days. Feel free to re-open this if it has been closed in error. If you do not have repository permissions to reopen the PR, please tag a maintainer.

@github-actionsgithub-actionsBot added the Status: stale-warning Issues and PRs flagged as stale which are due to be closed if no indication otherwise label Aug 27, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changesAwaiting changesComponent: PythonStatus: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@MartinNowak@AlenkaF@raulcd