Skip to main content

Module types

Module types 

Source
Expand description

ToSql and FromSql are also implemented for Option<T> where T implements ToSql or FromSql for the cases where you want to know if a value was NULL (which gets translated to None).

§Dynamic value compatibility notes

Type, Value, and ValueRef are non-exhaustive. Downstream code matching these enums should include a wildcard arm so new DuckDB types can be added without another source break.

Top-level UHUGEINT result values use Value::UHugeInt and ValueRef::UHugeInt when DuckDB reports UHUGEINT logical metadata for the result column. Nested UHUGEINT values inside lists, structs, maps, arrays, and unions do not currently carry DuckDB child logical type metadata through the borrowed container API, so values above i128::MAX cannot recover their u128 value from those metadata-less carriers.

Parameter-derived scale-zero Arrow decimal result columns are intentionally not guessed. DuckDB can report Invalid logical metadata for a bare bound parameter (SELECT ?) even when the bound value is u128. In that case duckdb-rs preserves the existing signed Value::HugeInt fallback instead of inferring UHUGEINT, HUGEINT, or DECIMAL from parameter names, aliases, or expression text. Cast the result expression so DuckDB reports stable logical metadata when a dynamic UHUGEINT carrier is required.

DuckDB DECIMAL values use Decimal, a full-domain carrier storing DuckDB’s decimal width, scale, and scaled integer payload. Reading a Decimal as f32 or f64 preserves its fractional component but still inherits normal binary floating-point precision loss. Read Decimal directly when exact decimal transport matters. Enable the rust_decimal feature for compatibility impls that convert to and from rust_decimal::Decimal when the value fits that crate’s smaller decimal domain, including compatibility reads from FLOAT, DOUBLE, and text columns.

Arrow decimal result values use Value::Decimal and ValueRef::Decimal directly except for scale-zero Decimal128(38, 0), which is also the Arrow shape DuckDB uses for HUGEINT and UHUGEINT. Top-level result columns use DuckDB logical metadata to distinguish those cases when DuckDB reports it. Narrower scale-zero DECIMAL widths are unambiguous and materialize as Decimal rather than the legacy signed Value::HugeInt fallback. Metadata-less scale-zero Decimal128(38, 0) values preserve the existing signed Value::HugeInt fallback. This affects parameter-derived expressions where DuckDB reports Invalid metadata, and nested container children where the borrowed container API does not carry DuckDB child logical metadata.

DuckDB GEOMETRY values use Value::Geometry and ValueRef::Geometry, backed by WKB bytes. CRS data is exposed as logical type metadata through crate::core::LogicalTypeHandle::geometry_crs rather than on each value. Nested GEOMETRY values inside lists, structs, maps, arrays, and unions do not currently carry DuckDB child logical type metadata through the borrowed container API, so they materialize through their Arrow binary carrier as Value::Blob values.

Structs§

Decimal
A DuckDB DECIMAL(width, scale) value.
DuckString
Wrapper for underlying duck string type with a lifetime bound to a &mut duckdb_string_t
Null
Empty struct that can be used to fill in a query parameter as NULL.
OrderedMap
An ordered map of key-value pairs.

Enums§

DecimalError
Error returned when constructing an invalid Decimal.
EnumType
Wrapper type for different enum sizes
FromSqlError
Enum listing possible errors from FromSql trait.
ListType
Wrapper type for different list sizes
TimeUnit
An absolute length of time in seconds, milliseconds, microseconds or nanoseconds. Copy from arrow::datatypes::TimeUnit
ToSqlOutput
ToSqlOutput represents the possible output types for implementers of the ToSql trait.
Type
DuckDB data types. See Fundamental Datatypes.
Value
Owning dynamic type value. Value’s type is typically dictated by DuckDB (not by the caller).
ValueRef
A non-owning static type value. Typically the memory backing this value is owned by DuckDB.

Traits§

FromSql
A trait for types that can be created from a DuckDB value.
ToSql
A trait for types that can be converted into DuckDB values. Returns Error::ToSqlConversionFailure if the conversion fails.

Type Aliases§

FromSqlResult
Result type for implementors of the FromSql trait.