write_parquet ignores write_options when compression is a ParquetWriterOptions
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Beginne mit dem für ParquetWriterOptions gezeigten DataFrame.write_parquet-Zweig und vergleiche seine Delegation mit write_parquet_with_options. Reproduziere den Partitionierungsfall mit DataFrameWriteOptions und überprüfe anschließend, dass der Regressionstest und die vorhandenen write-parquet-Tests mit weitergereichtem partition_by und den übrigen Optionen erfolgreich sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 605
- Forks
- 176
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 9
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/datafusion-python
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
apache/datafusion-python#1757 ·
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion-python#1726 ·
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 88/100
apache/datafusion-python#1691 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/datafusion-python#1644 ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
apache/datafusion-python#1737 ·
Alle Issues in apache/datafusion-python
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
-
hcocena Offenpolicies-accepted pre-review precheck-passed
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Bioconductor/BiocContributions#214 · 5 Kommentare ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
TencentCloud/Octop#1169 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
521xueweihan/HelloGitHub#3778 ·
-
The version checker's trailing attribute region has no control for a less-than inside a quoted value Offenarea: dashboard area: tests bug perceived difficulty: 2 python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Nitjsefnie-Harness-Commons/daedalus#1105 · 1 Kommentar ·