Skip to content

fix: Default engine as streaming for collect_batches#26932

Merged
ritchie46 merged 5 commits intomainfrom
nxs/collect-batches-streaming
Mar 16, 2026
Merged

fix: Default engine as streaming for collect_batches#26932
ritchie46 merged 5 commits intomainfrom
nxs/collect-batches-streaming

Conversation

@nameexhaustion
Copy link
Copy Markdown
Collaborator

@nameexhaustion nameexhaustion commented Mar 16, 2026

Default to the streaming engine for collect_batches.

Presumably we didn't respect the engine parameter for collect_batches in the past and defaulted to the streaming engine, in this PR we set it explicitly to the streaming engine if it's "auto"

@github-actions github-actions Bot added A-streaming Related to the streaming engine fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Mar 16, 2026
@nameexhaustion nameexhaustion force-pushed the nxs/collect-batches-streaming branch from e5d5807 to 0cba00b Compare March 16, 2026 13:08
@nameexhaustion nameexhaustion marked this pull request as ready for review March 16, 2026 13:18
@nameexhaustion nameexhaustion marked this pull request as draft March 16, 2026 13:21
@nameexhaustion nameexhaustion marked this pull request as ready for review March 16, 2026 13:22
chunk_size: int | None = None,
maintain_order: bool = True,
lazy: bool = False,
engine: EngineType = "auto",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain "auto", but we should decide lower-level where we dispatch to.

Comment thread py-polars/src/polars/lazyframe/frame.py Outdated
>>> for df in lf.collect_batches():
... print(df) # doctest: +SKIP
"""
engine = "streaming" if engine == "auto" else _select_engine(engine)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_select_engine should go first as that check engine affinity.`

        engine = _select_engine(engine)
        engine = "streaming" if engine == "auto" else engine

@ritchie46 ritchie46 merged commit 72a083f into main Mar 16, 2026
20 checks passed
@ritchie46 ritchie46 deleted the nxs/collect-batches-streaming branch March 16, 2026 14:10
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.74%. Comparing base (c5825d6) to head (983ec99).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26932      +/-   ##
==========================================
+ Coverage   81.72%   81.74%   +0.01%     
==========================================
  Files        1806     1806              
  Lines      248701   248742      +41     
  Branches     3133     3134       +1     
==========================================
+ Hits       203263   203326      +63     
+ Misses      44633    44611      -22     
  Partials      805      805              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-streaming Related to the streaming engine fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polars 1.39 performance issue in collect_batches()

2 participants