What this thread does
Do first: replace eager input loading with pl.scan_parquet(...) or pl.scan_csv(...), then write the lazy result using sink_parquet(..., engine="streaming").
Short answer
As of November 2026, this card targets Polars 2.1.0. The October 27, 2026 announcement adds out-of-core streaming group-by/window support; it does not promise that every expression or output fits a fixed process budget. Streaming input, spilling intermediate state and avoiding final collection address different allocations.
Choose / don't choose
- scan_parquet: choose when only selected columns/rows or a multi-step pipeline are needed; the query optimizer can push down predicates and projections to the scan level. Do not use read_parquet(...).lazy() to avoid the eager read (scan; read warning).
- read_parquet: choose only when the requested eager table fits comfortably in RAM.
- Disk sink: choose when final output exceeds RAM; streaming collect still returns the complete DataFrame.
Not for: pandas MemoryError repairs; see pandas-memoryerror-big-csv-fewer-columns-dtypes-parquet-chunks.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
schema_overrides | {"account_id": pl.String} for identifier text; declare remaining known types consistently across files | Polars baseline above | CSV scan |
null_values | Default None; set a string/list or column-to-sentinel dictionary only from the export contract | Polars baseline above | CSV scan |
infer_schema | False reads unspecified columns as String for diagnosing conflicting values; avoid full-file inference as a memory fix | Polars baseline above | CSV scan |
engine | "streaming" explicitly; current default "auto"; avoid "in-memory" for oversized results | Polars current sink docs | sink |
POLARS_OOC_MEMORY_BUDGET_MB | Official example 200, set before importing Polars | Polars baseline above | out-of-core |
POLARS_OOC_LOG_METRICS | 1 enables spill diagnostics; set before importing Polars | Polars baseline above | out-of-core |
show_graph | plan_stage="physical", engine="streaming" the legend shows how memory intensive the operation can be | Polars current streaming docs | physical plan |
Order of operations
1. Inventory the actual input schemas and business invariants on a small representative slice, including late bad types, nulls and leading-zero IDs. Use scans from the start instead of a pandas or eager Polars intermediate. 2. Place select/filter on each lazy scan before expensive joins and aggregations whenever semantics permit; retain columns required by later predicates. Inspect the optimized plan to see which projections/predicates reach the scan; do not move a predicate across an outer join if it changes retained rows (sources/sinks; Parquet scan). 3. Inspect the physical streaming graph. Locate eager reads, collect/to_pandas handoffs, Python functions, in-memory fallbacks and high-cardinality join/group state. Remove accidental materialization; isolate a nonstreaming stage or rewrite expressions while comparing results by stable keys (streaming guide). 4. Write to a new disk-backed destination with sink_parquet. For supported spilling operators set the budget before import and monitor spill metrics, peak process memory and remaining disk. Chris Parmer’s November 3, 2026 experiment distinguishes POLARS_OOC_SPILL_DIR from POLARS_TEMP_DIR; avoid memory-backed spill storage. 5. Read the output with a new scan, compare schema, row totals, null behavior and business aggregates, collecting only bounded summaries. Compare gab23r’s expression alternatives on the actual data before adopting one; preserve ordering explicitly if required. Promote the new output only after completeness checks.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
in-memory-map | In gab23r’s October 28, 2026 report, grouped unique().drop_nulls() falls back to in-memory execution | Inspect the graph; the report’s unique() then list.drop_nulls() uses native grouped execution. Compare semantics/results before rewriting | report |
Memory limits and missing inputs
- collect returns the output DataFrame even when execution streams; a memory budget for intermediate spilling cannot bound the final DataFrame. collect
- No input, join cardinalities, memory allowance or free disk is specified. Native spilling support is operator-specific; Python functions and skewed intermediate state may still require a partitioned rewrite.
Checked
2026-11-12; Polars; 2.1.0 release; scan/sink/streaming guides, announcement, Chris Parmer experiment and gab23r report read. No application commands were executed.
Started from a post by @Polars team, packaged by the editor. Original post