Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

write_parquet ignores write_options when compression is a ParquetWriterOptions

オープン 初心者向け
#1,760 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
data

調査の方向性

ParquetWriterOptions について示されている DataFrame.write_parquet ブランチから始め、その委譲を write_parquet_with_options と比較します。DataFrameWriteOptions を使ってパーティショニングのケースを再現し、その後、回帰テストと既存の write-parquet テストが partition_by およびその他のオプションが転送された状態でパスすることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

DataFrame.write_parquet accepts write_options: DataFrameWriteOptions | None, documents it ("Options that impact how the DataFrame is written") and declares it in the @overload for the ParquetWriterOptions form. But that branch delegates without forwarding it:

if isinstance(compression, ParquetWriterOptions):
    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)   # write_options dropped
    return

write_parquet_with_options(path, options, write_options=None) takes the parameter, so everything in DataFrameWriteOptions (partition_by, single_file_output, insert_operation, sort_by) is silently ignored whenever the compression argument is a ParquetWriterOptions. No error, no warning: the files just land in the wrong layout.

To Reproduce

import tempfile, pathlib
from datafusion import SessionContext
from datafusion.dataframe import ParquetWriterOptions, DataFrameWriteOptions

ctx = SessionContext()
df = ctx.from_pydict({"part": ["a", "a", "b"], "v": [1, 2, 3]})
wo = lambda: DataFrameWriteOptions(partition_by="part")

with tempfile.TemporaryDirectory() as d:
    out = pathlib.Path(d) / "x"
    df.write_parquet(out, ParquetWriterOptions(), write_options=wo())
    print(sorted(p.name for p in out.iterdir()))

Measured with datafusion 54.0.0:

write_parquet(ParquetWriterOptions, write_options)   ['IDuOjvMa3pdEDotb_0.parquet']   <-- not partitioned
write_parquet_with_options(..., write_options)       ['part=a', 'part=b']
write_parquet('zstd', write_options)                 ['part=a', 'part=b']

Same DataFrameWriteOptions in all three calls; only the ParquetWriterOptions branch loses the Hive partitioning.

Expected behavior

The Hive partitioning, and the rest of write_options, should be applied, exactly as the other two spellings already do: ['part=a', 'part=b'].

Additional context

The branch was added in ef62fa89 (#1169, "Add compression_level support to ParquetWriterOptions and enhance write_parquet to accept full options object"), while write_options came earlier in #857, so the new delegation path was written without carrying over the existing parameter. Note that the same if explicitly refuses compression_level with a ValueError, so incompatible arguments in this branch are rejected on purpose when intended; write_options was not refused, just not passed along.

I have a one-line fix plus a regression test ready and will open a PR against this issue.

主要言語
Python
スター
605
フォーク
176
平均マージ
1日 23時間
マージ済み PR(30日)
9

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion-python のほかの issue

apache/datafusion-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。