Skip to content
Open
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
2 changes: 1 addition & 1 deletion python/datafusion/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ def write_parquet(
if compression_level is not None:
msg = "compression_level should be None when using ParquetWriterOptions"
raise ValueError(msg)
self.write_parquet_with_options(path, compression)
self.write_parquet_with_options(path, compression, write_options)
return

if isinstance(compression, str):
Expand Down
19 changes: 19 additions & 0 deletions python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,25 @@ def test_write_parquet(df, tmp_path, path_to_str):
assert result == expected


def test_write_parquet_writer_options_keeps_write_options(ctx, tmp_path):
"""``write_parquet`` honours ``write_options`` alongside ``ParquetWriterOptions``.

The ``ParquetWriterOptions`` branch delegates to
:py:meth:`DataFrame.write_parquet_with_options`, which takes ``write_options``
too, so ``partition_by`` must still reach the writer.
"""
df = ctx.from_pydict({"part": ["a", "a", "b"], "v": [1, 2, 3]})
path = tmp_path / "partitioned"

df.write_parquet(
path,
ParquetWriterOptions(),
write_options=DataFrameWriteOptions(partition_by="part"),
)

assert sorted(p.name for p in path.iterdir()) == ["part=a", "part=b"]


@pytest.mark.parametrize(
("compression", "compression_level"),
[("gzip", 6), ("brotli", 7), ("zstd", 15)],
Expand Down