Skip to main content

reference_value

Function reference_value 

Source
pub unsafe fn reference_value(vector: duckdb_vector, value: &Value)
Expand description

Fills vector with a single constant value.

duckdb.h: “Copies the value from value to vector.” This is how an extension emits “the same answer for every row” without writing it row by row, and it is what DuckDB does internally for a constant expression.

§Safety

  • vector must be a valid, writable vector.
  • value’s logical type must equal the vector’s exactly. DuckDB does not reinterpret a mismatched value: it sizes the buffers from the value’s type, casts the value (aborting the process when the cast throws, as for 'abc' into BIGINT), and writes data of the vector’s type into those buffers, so a narrower value type can overflow them and a NULL of the wrong type (such as Value::null_value) leaves a LIST vector without its child buffer. To fill a vector with NULL, use a typed NULL of the vector’s own type.
  • As with slice(), the result is not a flat vector: do not read it back through a VectorReader.