You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Split oversized record batches when streaming writes #4499
Since #3447, tbl.append() and tbl.overwrite() accept any Arrow PyCapsule stream, such as a Polars DataFrame, and stream it into unpartitioned tables through bin_pack_record_batches. That function never splits a batch, and a Polars DataFrame built in one go exports a single chunk, so the whole frame ends up in one data file regardless of write.target-file-size-bytes. Converting with pa.table(df) first goes through bin_pack_arrow_table, which does split by rows.
With 500k rows and write.target-file-size-bytes=1048576 on an unpartitioned table:
tbl.append(pa.table(polars_df)) # 18 data filestbl.append(polars_df) # 1 data file
The same applies to any pa.RecordBatchReader that yields large batches.
Proposal: in bin_pack_record_batches, slice an incoming batch that would push the buffer past the target size (RecordBatch.slice is zero copy), so streamed input honors the target file size the same way pa.Table input does. Once that's in, the "A streamed batch is never split" note in mkdocs/docs/api.md can be dropped.
Activity