Requires
feature = "columnar" (or udf). better_duck_core::{VectorRef, VectorMut, FixedWidth}.DataChunkHandle exposes each column as a vector view: VectorRef for
reading (vector(idx)) and VectorMut for writing (vector_mut(idx)). The borrow checker enforces
their aliasing rules — many VectorRefs may coexist; a VectorMut is exclusive.
VectorRef — reading a column
Built from&DataChunkHandle, so read views coexist freely.
A zero-copy
&[T] over a fixed-width column. Checks the column’s type id against T; a mismatch
is Error::ConversionError. Does not mask NULLs — see the warning below.Read one value as
T (the fixed-width scalars, i128 / u128, &str, String, Option<T>).Decode one row dynamically, reusing the query-result decoder — works for any column type,
not just fixed-width.
Whether
row is NULL.Packed validity words (bit
r % 64 of word r / 64 set ⇒ row r is valid), or None when the
column has no NULLs (DuckDB elides the mask).VectorMut — writing a column
Built from&mut DataChunkHandle, so the borrow checker guarantees it is the only live view of that
column (closing an aliasing hole present in some other DuckDB bindings).
Write one value (the fixed-width scalars,
i128 / u128, &str, String, Option<T> where
None writes NULL).Mark the row NULL.
Mark the row valid (un-mask when reusing a chunk).
Set NULL/valid in one call.
The FixedWidth marker
FixedWidth (a sealed trait) marks the scalars whose DuckDB physical representation is a packed
native array — enabling the zero-copy as_slice read. It is implemented for bool, i8 / i16 /
i32 / i64, u8 / u16 / u32 / u64, and f32 / f64.
It is not implemented for:
i128/u128— DuckDB uses hugeint struct storage;String/&str— variable width.
get / as_duck_value instead of as_slice.
See also
- Data chunks — allocating and shaping the chunk these views come from.
- Columnar overview —
fetch_chunkand the row-vs-chunk rule. - Scalar functions —
invokereads inputs and writes output through these views.