Python Polars 2.2.0 came out on 24 November 2026, and the headline feature is out-of-core joins. The streaming engine can now join tables whose build side is bigger than your memory budget by spilling partitions to disk. The release also includes three breaking changes you should check before upgrading. This guide walks through both.
Upgrade
pip install --upgrade "polars>=2.2"
python -c "import polars as pl; print(pl.__version__)"
The full list of changes is in the Polars 2.2.0 release notes.
What “out-of-core joins” means
In a hash join, Polars builds a hash table from one input (the build side) and streams the other input (the probe side) through it. Before this release, the streaming engine could spill the build side’s payload to disk, but the hash tables themselves had to fit in memory. A very large build side could still run you out of RAM.
PR #30679 changes that. Once the build side has arrived, the join estimates how big its hash tables will be and asks for a memory grant:
- If everything fits, the join works as before and builds all tables in memory.
- If it doesn’t fit, the build side is split by key hash into partitions stored as frames that can be spilled to disk. Polars builds tables right away for the smallest partitions that fit the grant, so part of the join still runs in memory.
- Probe rows for in-memory partitions are matched immediately. Probe rows for stored partitions are written next to their build rows.
- When the probe input ends, each stored partition is joined in turn. Every finished table gives its memory back to the grant, which makes room for the next partition.
The memory grant system comes from PR #30524. By default, 75% of total system memory is available for granting, and the out-of-core hash join asks for up to two-thirds of what’s left in the pool when it needs memory.
Current limits
The PR is clear about what’s covered so far:
- Only equi-joins without
maintain_order. - Semi and anti joins still build their whole table in memory.
- Joins with
maintain_order=Truecan spill their build input but still build every table in memory. - With heavily skewed keys (one very common key), a single partition can still exceed the grant, because the join always builds at least one table.
Using it: run your join on the streaming engine
Out-of-core execution belongs to the streaming engine, so build your query with the lazy API and either collect with engine="streaming" or sink straight to a file. The streaming concepts page documents the engine="streaming" argument.
import polars as pl
orders = pl.scan_parquet("data/orders/*.parquet") # very large
customers = pl.scan_parquet("data/customers/*.parquet") # large too
enriched = (
orders
.join(customers, on="customer_id", how="inner")
.group_by("country")
.agg(
pl.len().alias("orders"),
pl.col("amount").sum().alias("revenue"),
)
)
result = enriched.collect(engine="streaming")
print(result.sort("revenue", descending=True).head())
When the joined result itself is huge, don’t collect it. Write it to disk as you go:
(
orders
.join(customers, on="customer_id", how="left")
.sink_parquet("out/orders_enriched.parquet")
)
A few practical tips:
- Leave
maintain_orderoff (the default) unless you really need input order. Ordered joins don’t get the full out-of-core path yet. - Filter and select early. Polars pushes projections and predicates down, but explicit
select()calls on wide tables still cut the bytes that might need spilling. - Use fast local disk for temporary files. Spilling to a network drive works, but it’s slow.
- Inspect plans with
LazyFrame.explain()to check that filters and projections were pushed into the scans.
Other join speed-ups in 2.2
The release has a long list of performance work around joins, including:
- Using estimated row counts to choose the build side of streaming equi-joins
- Packing multi-column join and group-by keys into fixed-width integers
- Skipping the probe side of joins that have no non-null build keys
- An exact bitset runtime filter for integer join keys in a small range
- Reordering inner, semi and anti joins below left joins in more cases
You get these for free on upgrade, with no code changes needed.
Breaking change 1: str.find now returns character offsets
PR #31026 fixes an inconsistency. Expr.str.find and str.find_many returned byte offsets, while the rest of Polars (and Python slicing) uses code-point offsets. From 2.2 they return character offsets. This only matters for non-ASCII text:
import polars as pl
s = pl.Series(["héllo", "hello"])
print(s.str.find("l").to_list())
# Polars 2.2: [2, 2] (character positions)
# Before 2.2: [3, 2] ("é" is two bytes in UTF-8)
If you used str.find results with str.slice, your code probably gets more correct after upgrading. If you really need byte offsets, for example when working with raw binary data, there’s a new unstable Expr.bin.find and bin.find_many that still use bytes.
Breaking change 2: scalar arguments are checked at plan time
PR #30914 makes Polars check arguments that must be a single value while it plans the query, not while it runs. Before, any expression that happened to return one row was accepted, so whether a query worked depended on your data.
Affected arguments include the offset and length of head/tail/limit/slice, k in top_k/bottom_k, n/fraction in sample, the quantile in quantile, n in pct_change and the index of get.
df = pl.DataFrame({"a": [5, 3, 9, 1], "n": [2, 2, 2, 2]})
# Now raises ShapeError at planning time
# df.select(pl.col("a").head(pl.col("n").head(1)))
# Works: make the argument an explicit scalar
print(df.select(pl.col("a").head(pl.col("n").first())))
The error message points you to .item(), .first() or .implode(). Also note that str.contains_any and str.replace_many no longer accept a one-row Series literal. Pass a plain Python list instead.
Breaking change 3: SQL DELETE changes the registered table
In a SQLContext, a SQL DELETE statement now changes the registered table itself (#30869). If your code runs DELETE through a SQLContext, check what the registered table holds afterwards and update any tests that assumed the old behaviour.
Upgrade checklist
- Search your code for
str.find(andstr.find_many(and check any logic that mixes the results with byte-based tools. - Run your test suite and look for new
ShapeErrorexceptions at planning time. Fix them with.first()or.item(). - Check uses of
SQLContextwithDELETE. - Switch big joins to
collect(engine="streaming")orsink_parquet()and watch peak memory.
Takeaway
Polars 2.2 makes the streaming engine much harder to knock over. Large equi-joins can now spill partitions to disk instead of failing. Upgrade, move heavy joins onto engine="streaming", and spend ten minutes on the three breaking changes, especially the switch to character offsets in str.find.
