write_parquet ignores write_options when compression is a ParquetWriterOptions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu từ nhánh DataFrame.write_parquet được nêu cho ParquetWriterOptions và so sánh việc ủy quyền của nó với write_parquet_with_options. Tái hiện trường hợp phân vùng bằng DataFrameWriteOptions, sau đó xác minh rằng bài kiểm thử hồi quy và các bài kiểm thử write-parquet hiện có đều vượt qua khi partition_by và các tùy chọn khác được chuyển tiếp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 605
- Fork
- 176
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 9
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/datafusion-python
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/datafusion-python#1757 ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion-python#1726 ·
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 88/100
apache/datafusion-python#1691 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-python#1644 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
apache/datafusion-python#1737 ·
Tất cả issue của apache/datafusion-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
hcocena Đang mởpolicies-accepted pre-review precheck-passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Bioconductor/BiocContributions#214 · 5 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
TencentCloud/Octop#1169 · 1 bình luận ·
-
[开源推荐] 在老板拷问你之前,先让 AI 灵魂拷问你 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
521xueweihan/HelloGitHub#3778 ·
-
The version checker's trailing attribute region has no control for a less-than inside a quoted value Đang mởarea: dashboard area: tests bug perceived difficulty: 2 python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Nitjsefnie-Harness-Commons/daedalus#1105 · 1 bình luận ·