Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-39440: [Python] Calling pyarrow.dataset.ParquetFileFormat.make_write_options as a class method results in a segfault #40976

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/pyarrow/_dataset_parquet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ cdef class ParquetFileFormat(FileFormat):
-------
pyarrow.dataset.FileWriteOptions
"""
# Safeguard from calling make_write_options as a static class method
if not isinstance(self, ParquetFileFormat):
raise TypeError("make_write_options() should be called on "
"an instance of ParquetFileFormat")
opts = FileFormat.make_write_options(self)
(<ParquetFileWriteOptions> opts).update(**kwargs)
return opts
Expand Down
13 changes: 13 additions & 0 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5630,3 +5630,16 @@ def test_checksum_write_dataset_read_dataset_to_table(tempdir):
corrupted_dir_path,
format=pq_read_format_crc
).to_table()


def test_make_write_options_error():
# GH-39440
msg = ("make_write_options\\(\\) should be called on an "
"instance of ParquetFileFormat")
with pytest.raises(TypeError, match=msg):
pa.dataset.ParquetFileFormat.make_write_options(43)

pformat = pa.dataset.ParquetFileFormat()
msg = "make_write_options\\(\\) takes exactly 0 positional arguments"
with pytest.raises(TypeError, match=msg):
pformat.make_write_options(43)
Loading