Streams a DuckDB table through a batch plan and applies a user-defined function to each batch. The function must accept a data.frame and return a data.frame. Results can be collected in memory or written back to DuckDB incrementally.
Arguments
- plan
A batch plan produced by
duckdb_batch_plan(). Must include columnsbatch_idandrow_count, plus either row-number windows (row_start,row_end), block identifier columns, or ablockslist-column for consolidated batches.- con
A DuckDB connection.
- input_table
Character. Name of the source table in DuckDB.
- fn
A function applied to each batch. Receives a data.frame and must return a data.frame.
- persist
Logical. If
TRUE, results of each batch are appended tooutput_tableinside DuckDB and a lazy table reference is returned. IfFALSE, returns a list of batch results as data.frames.- output_table
Optional DuckDB table name where results are stored when
persist = TRUE. If omitted, a random temporary table name is generated. Ignored whenpersist = FALSE.
