Skip to content

Commit

Permalink
fix: datafusion: ensure that to_pyarrow_batches does do compute
Browse files Browse the repository at this point in the history
  • Loading branch information
dlovell authored and jcrist committed Feb 27, 2024
1 parent 99dda5b commit d1a62d0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ibis/backends/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,8 @@ def to_pyarrow_batches(

struct_schema = schema.as_struct().to_pyarrow()

return pa.ipc.RecordBatchReader.from_batches(
schema.to_pyarrow(),
(
def make_gen():
yield from (
# convert the renamed + casted columns into a record batch
pa.RecordBatch.from_struct_array(
# rename columns to match schema because datafusion lowercases things
Expand All @@ -522,7 +521,11 @@ def to_pyarrow_batches(
.cast(struct_schema)
)
for batch in frame.collect()
),
)

return pa.ipc.RecordBatchReader.from_batches(
schema.to_pyarrow(),
make_gen(),
)

def to_pyarrow(self, expr: ir.Expr, **kwargs: Any) -> pa.Table:
Expand Down

0 comments on commit d1a62d0

Please sign in to comment.