Skip to main content
Requires feature = "columnar" (also turned on by udf). The types re-export at the crate root: better_duck_core::{DataChunkHandle, VectorRef, VectorMut, FixedWidth}.
The columnar feature adds a columnar read/write path alongside the row-oriented API: pull query results as data chunks, read fixed-width columns zero-copy, and build chunks to bulk-insert. It is the same data-chunk machinery user-defined functions use.

Reading results as chunks

DuckResult::fetch_chunk() -> Option<Result<DataChunkHandle>> pulls the next chunk directly, bypassing per-row DuckRow materialization. None means the result is exhausted.
The row-vs-chunk rule. A DuckResult is consumed either row-by-row (next / exists / count / materialize) or chunk-by-chunk (fetch_chunk), never both — they share one cursor. The first method used fixes the mode:
  • A row call after fetch_chunk → the row call returns Err(Error::MixedIterationMode).
  • fetch_chunk after any row call → Some(Err(Error::MixedIterationMode)).
Pick one mode per result. See Error::MixedIterationMode.

When to go columnar

Columnar

Analytical scans over fixed-width columns, where as_slice gives a zero-copy &[T]; or building chunks to bulk-append. Minimal per-value overhead.

Row-oriented

Mixed-type rows, random column access by name, or small results. Simpler and always available.

The pieces

DataChunkHandle

An owned-or-borrowed batch of columns: len, capacity, vector / vector_mut, set_len, reset.

Vectors

VectorRef (read) and VectorMut (write), the FixedWidth marker, and validity masks.

See also