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 1 commit
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
3 changes: 3 additions & 0 deletions python/pyarrow/_dataset_parquet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ cdef class ParquetFileFormat(FileFormat):
-------
pyarrow.dataset.FileWriteOptions
"""
if not isinstance(self, ParquetFileFormat):
raise TypeError("pyarrow.dataset.ParquetFileFormat() must be initiated"
" before calling make_write_options()")
AlenkaF marked this conversation as resolved.
Show resolved Hide resolved
opts = FileFormat.make_write_options(self)
(<ParquetFileWriteOptions> opts).update(**kwargs)
return opts
Expand Down
12 changes: 12 additions & 0 deletions python/pyarrow/tests/test_dataset_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,15 @@ def unwrap_key(self, wrapped_key: bytes, _: str) -> bytes:
dataset = ds.dataset(path, format=file_format, filesystem=mockfs)
new_table = dataset.to_table()
assert table == new_table


def test_make_write_options_error():
AlenkaF marked this conversation as resolved.
Show resolved Hide resolved
# GH-39440
msg = "ParquetFileFormat\\(\\) must be initiated before calling make_write_options"
AlenkaF marked this conversation as resolved.
Show resolved Hide resolved
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