Skip to content

Commit 703507f

Browse files
committed
feat(polars): add streaming kwarg to to_pandas
1 parent 36e1db5 commit 703507f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docs/posts/pydata-performance-part2/polars_ibis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
.dropna("ext")
3131
.order_by([_.month.desc(), _.project_count.desc()])
3232
)
33-
df = expr.to_pandas()
33+
df = expr.to_pandas(streaming=True)

ibis/backends/polars/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,16 @@ def execute(
404404
expr: ir.Expr,
405405
params: Mapping[ir.Expr, object] | None = None,
406406
limit: int | None = None,
407+
streaming: bool = False,
407408
**kwargs: Any,
408409
):
409410
lf = self.compile(expr, params=params, **kwargs)
410411
if limit == "default":
411412
limit = ibis.options.sql.default_limit
412413
if limit is not None:
413-
df = lf.fetch(limit, streaming=True)
414+
df = lf.fetch(limit, streaming=streaming)
414415
else:
415-
df = lf.collect(streaming=True)
416+
df = lf.collect(streaming=streaming)
416417

417418
if isinstance(expr, (ir.Table, ir.Scalar)):
418419
return expr.__pandas_result__(df.to_pandas())
@@ -429,13 +430,14 @@ def _to_pyarrow_table(
429430
expr: ir.Expr,
430431
params: Mapping[ir.Expr, object] | None = None,
431432
limit: int | None = None,
433+
streaming: bool = False,
432434
**kwargs: Any,
433435
):
434436
lf = self.compile(expr, params=params, **kwargs)
435437
if limit is not None:
436-
df = lf.fetch(limit, streaming=True)
438+
df = lf.fetch(limit, streaming=streaming)
437439
else:
438-
df = lf.collect(streaming=True)
440+
df = lf.collect(streaming=streaming)
439441

440442
table = df.to_arrow()
441443
if isinstance(expr, (ir.Table, ir.Value)):

0 commit comments

Comments
 (0)