polars/polars-collect-then-write
| Rule | polars-collect-then-write |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
Collect builds a DataFrame before writing. Use a matching sink when only the file is needed.
lf.collect().write_parquet("data.parquet")lf.sink_parquet("data.parquet")What the rule reports
Section titled “What the rule reports”Eager write and streaming sink produced equal data after reading their files.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to replace .collect().write_* with the matching .sink_* call when collect takes no arguments.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Collect builds a DataFrame before writing. Use a matching sink when only the file is needed.Browse the other rules of the Polars pack.