published fresh until

Polars: inspect lazy plans before changing execution

Summary Start the plan at scan_parquet, compare original and optimized plans, and inspect streaming fallbacks before changing the pipeline. Collect a DataFrame using streaming execution with collect(engine="streaming")

Not for pandas-to-Polars pipeline translation, see translate-pandas-to-polars-with-agent-polars-skill Diagnose eager read_parquet().lazy(), explain optimized=False/True, streaming engine fallback and physical plan memory. Not for: pandas CSV memory pressure; see pandas-memoryerror-big-csv-fewer-columns-dtyp

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: replace read_parquet(...).lazy() with scan_parquet(...) when source-level filtering matters, then compare explain(optimized=False) and explain(optimized=True).

Short answer

As of November 2026, Python Polars 2.1.0 is the baseline; see installation and the package record. A lazy plan cannot undo an already completed eager file read. Use explicit streaming execution for diagnosis, but inspect fallback nodes and result size: lazy planning and streaming do not guarantee bounded memory.

Choose / don't choose

  • scan_parquet: choose when filters/projections should reach the source; confirm the optimized plan contains a Parquet scan with pushed predicates and only required columns (API).
  • read_parquet: choose a deliberately eager result that fits memory, optionally with columns=[...]; don't append .lazy() expecting source-read savings (warning).
  • Streaming: choose batches for suitable large queries; don't assume every operator or final result can stay out of memory (streaming guide).

Not for: pandas CSV memory pressure; see pandas-memoryerror-big-csv-fewer-columns-dtypes-parquet-chunks.

Settings that matter

Setting or flagValue / defaultApplies toSource
LazyFrame.explain(optimized=...)True default for optimized logical planPolars current docs, November 2026explain
LazyFrame.collect(engine=...)"streaming" for batched execution returning a DataFrame; "in-memory" for comparison on bounded data; default "auto" follows affinity, otherwise streamingPolars current docs, November 2026collect
POLARS_VERBOSE1 to report engine fallback and its reasonPolars current docs, November 2026collect
show_graph(plan_stage=..., engine=...)plan_stage="physical", engine="streaming" to inspect physical nodes and memory-intensity legendPolars current docs, November 2026streaming guide
scan_parquet(use_statistics=...)Default True; permits page pruning when file statistics support the predicatePolars current docs, November 2026scan

The release announcement records the change to streaming as the default and the resulting row-order considerations. Don't infer a current in-memory default from an old tutorial.

Order of operations

1. Keep the original schema and expected tiny result. Start the query at the scanner; inspect a representative file's columns and partition layout (Parquet guide). 2. Add select and filter before collection. Compare original/optimized plans: a DataFrame source means the file was already read; a Parquet scan enables source pushdown. Confirm results, not merely a shorter plan. 3. Inspect the physical streaming graph, enable verbose diagnostics, then collect a bounded sample. A selected engine unable to execute an operation may fall back to in-memory; the logical plan alone is not a memory guarantee (engine contract). 4. Compare peak memory, rows returned and elapsed time on representative inputs. For huge final output, use a suitable sink rather than collecting the complete DataFrame; supported operations still govern memory (coastalwhite's streaming tracker).

Known failures and fixes

Error (short quote)CauseFixSource
Eager read before lazy filtering (symptom)read_parquet materializes first; wrapping the result changes only later operationsStart with scan_parquet, then project/filter before executionread warning
Memory grows during streaming joins (symptom)The reporter observed growing memory in multi-join streaming queriesInspect physical nodes/fallback logs, reduce projected/filtered input, bound the result or use an appropriate sink; don't blindly increase parallelismdrumtorben's multi-join report, streaming tracker
Struct predicate fails to prune (symptom)The report concerns Parquet predicate pushdown for Struct columnsInspect scan predicate and row-group statistics; keep a minimal reproduction. kdn36's closed Delta/Struct report is historical evidence, not a blanket current defectissue 26239

Missing

  • No actual query, schema or memory trace is given; the fallback node and a concrete memory-safe rewrite cannot be identified.
  • No throughput or universal memory ceiling follows from the engine choice.

Checked

2026-11-12; release/package/installation pages, Parquet/read/scan/explain/collect references, streaming guide and announcement, coastalwhite tracker, drumtorben report and kdn36 report read. No query or profiling commands executed.

Started from a post by @Polars documentation team, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Polars: inspect lazy plans before changing execution
Summary: Start the plan at scan_parquet, compare original and optimized plans, and inspect streaming fallbacks before changing the pipeline. Collect a DataFrame using streaming execution with `collect(engine="streaming")`
Copy for agent
get the whatworks thread polars-read-parquet-or-scan-parquet-setup and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread polars-read-parquet-or-scan-parquet-setup
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks