Skip to main content
Requires feature = "columnar" (or udf). better_duck_core::DataChunkHandle.
A DataChunkHandle is a batch of rows laid out column-wise — one vector per column. You get one from DuckResult::fetch_chunk (DuckDB-owned, read-only in practice) or allocate one with new to build and append.

Allocating and building

API

Allocate a chunk with one LogicalType per column. Owned — destroyed on drop.
A read-only view of column idx. Many VectorRefs may coexist. InvalidColumnIndex out of range.
An exclusive, writable view of column idx.
A writable view of every column at once — disjoint by construction, so they may be held together.
Current valid row count.
Mark n valid rows. Errors if n > capacity().
DuckDB’s build-time vector size — the max rows per chunk. Read it, never hardcode a limit.
Column count.
The DuckDB type id of column idx. InvalidColumnIndex out of range.
Clear to zero rows, keeping the allocation to refill and append again.
reset() panics on a borrowed chunk — one obtained from a DuckDB callback frame rather than allocated with new. Only reset chunks you own. (A chunk from fetch_chunk is owned and may be reset.)

Capacity, not a constant

The vector size is a DuckDB build-time constant that can differ across builds. Loop until cap rather than assuming any particular value, and split large writes into multiple chunks of at most cap rows each.

See also