Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Table.toArrowBatchIterator

Table.toArrowBatchIterator([maxResults, options]) → AsyncGenerator<arrow.RecordBatch>

Returns an async iterator of arrow RecordBatches, for processing the table's data in a memory-efficient streaming manner. Nothing is read until iteration begins, and breaking out of the loop stops the read. When the table is read in parallel, batches arrive in no particular order.

Also callable on Queries, Uploads, and ReadStreams → query.toArrowBatchIterator(...) | upload.toArrowBatchIterator(...)

let count = 0;
for await (const batch of table.toArrowBatchIterator({ variables: ['FIRENAME', 'GISACRES'] })) {
  count += batch.numRows;
}

Parameters:

maxResults : number, optional The maximum number of rows to return. If not specified, all rows in the table will be read.

variables : string[], optional A list of variable names to read, improving performance when not all variables are needed. If unspecified, all variables will be represented in the returned rows. Variable names are case-insensitive, though the names in the results will reflect the variable's true casing. The order of the columns returned will correspond to the order of names in this list.

maxParallelization : number, default the number of CPU cores, up to 8 The maximum number of streams to read in parallel, for large reads.

batchPreprocessor : function, optional A function used to preprocess the data, invoked for each RecordBatch as it is read. It must return a RecordBatch (or a promise of one), or null to drop the batch.

onProgress : function, optional Called with { rowsRead, totalRows } as batches are read.

signal : AbortSignal, optional Cancels the read.

Returns: AsyncGenerator<arrow.RecordBatch>

Was this helpful?