#[non_exhaustive]pub enum TypeId {
Show 42 variants
Boolean,
TinyInt,
SmallInt,
Integer,
BigInt,
UTinyInt,
USmallInt,
UInteger,
UBigInt,
HugeInt,
Float,
Double,
Timestamp,
TimestampTz,
Date,
Time,
Interval,
Varchar,
Blob,
Decimal,
TimestampS,
TimestampMs,
TimestampNs,
Enum,
List,
Struct,
Map,
Uuid,
Union,
Bit,
TimeTz,
UHugeInt,
Array,
TimeNs,
Any,
Varint,
SqlNull,
IntegerLiteral,
StringLiteral,
Geometry,
Variant,
TimestampTzNs,
}Expand description
Identifies a DuckDB column type.
Use this in the aggregate function builders instead of the raw DUCKDB_TYPE_*
integer constants. This enum is non-exhaustive — new variants may be added as
DuckDB adds new types.
§Example
use quack_rs::types::TypeId;
let t = TypeId::BigInt;
assert_eq!(t.to_duckdb_type(), libduckdb_sys::DUCKDB_TYPE_DUCKDB_TYPE_BIGINT);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Boolean
BOOLEAN — true/false
TinyInt
TINYINT — 8-bit signed integer
SmallInt
SMALLINT — 16-bit signed integer
Integer
INTEGER — 32-bit signed integer
BigInt
BIGINT — 64-bit signed integer
UTinyInt
UTINYINT — 8-bit unsigned integer
USmallInt
USMALLINT — 16-bit unsigned integer
UInteger
UINTEGER — 32-bit unsigned integer
UBigInt
UBIGINT — 64-bit unsigned integer
HugeInt
HUGEINT — 128-bit signed integer
Float
FLOAT — 32-bit floating-point
Double
DOUBLE — 64-bit floating-point
Timestamp
TIMESTAMP — microseconds since epoch
TimestampTz
TIMESTAMP WITH TIME ZONE — timezone-aware timestamp
Date
DATE — days since epoch
Time
TIME — microseconds since midnight
Interval
INTERVAL — { months, days, micros }
Varchar
VARCHAR — UTF-8 string
Blob
BLOB — binary data
Decimal
DECIMAL — fixed-point decimal (width, scale)
TimestampS
TIMESTAMP_S — seconds since epoch
TimestampMs
TIMESTAMP_MS — milliseconds since epoch
TimestampNs
TIMESTAMP_NS — nanoseconds since epoch
Enum
ENUM — enumeration type
List
LIST — variable-length list
Struct
STRUCT — named fields (row type)
Map
MAP — key-value pairs (LIST of STRUCT)
Uuid
UUID — 128-bit UUID
Union
UNION — tagged union of types
Bit
BIT — bitstring
TimeTz
TIME WITH TIME ZONE — timezone-aware time
UHugeInt
UHUGEINT — 128-bit unsigned integer
Array
ARRAY — fixed-length array
TimeNs
TIME_NS — time of day with nanosecond precision (DuckDB 1.4.0+)
Any
ANY — wildcard type for function signatures
Used in function overload resolution to accept any input type. Not a concrete column type — typically used only in builder APIs.
Varint
BIGNUM — arbitrary-precision integer (called VARINT before DuckDB
1.4.0, and still accepted under that name)
Arbitrary-precision integer stored as a variable-length encoding.
Maps to DUCKDB_TYPE_BIGNUM in the C API.
SqlNull
SQLNULL — explicit SQL NULL type
Represents the type of a bare NULL literal before type resolution.
IntegerLiteral
INTEGER_LITERAL — integer literal type used during overload resolution
Internal type representing an unresolved integer literal in SQL. Not a
concrete column type — used by DuckDB’s type resolution system.
StringLiteral
STRING_LITERAL — string literal type used during overload resolution
Internal type representing an unresolved string literal in SQL. Not a
concrete column type — used by DuckDB’s type resolution system.
Geometry
GEOMETRY — spatial geometry value (DuckDB 1.5.x; requires duckdb-1-5-3)
Present in the C type enum as DUCKDB_TYPE_GEOMETRY (40). Gated behind
the duckdb-1-5-3 feature; see that feature’s documentation for the
version-floor rationale.
Variant
VARIANT — self-describing nested value, e.g. for Iceberg v3 (DuckDB 1.5.3; requires duckdb-1-5-3)
Added to the C type enum as DUCKDB_TYPE_VARIANT (41) in DuckDB 1.5.3.
TimestampTzNs
TIMESTAMPTZ_NS — timestamp with time zone at nanosecond precision,
nanoseconds since epoch (DuckDB 2.0.0+)
Added to the C type enum as DUCKDB_TYPE_TIMESTAMP_TZ_NS (42) in DuckDB
2.0.0. Stored exactly like TimestampNs: an i64
count of nanoseconds (read it with
VectorReader::read_timestamp_tz_ns).
This variant exists on every build, whatever bindings or features are
in use, because the id is a plain number. A DuckDB before 2.0.0 has no
such type: it never reports this id, and refuses to create the type.
Implementations§
Source§impl TypeId
impl TypeId
Sourcepub const fn to_duckdb_type(self) -> DUCKDB_TYPE
pub const fn to_duckdb_type(self) -> DUCKDB_TYPE
Converts this TypeId to the corresponding DuckDB C API type constant.
§Example
use quack_rs::types::TypeId;
assert_eq!(
TypeId::Timestamp.to_duckdb_type(),
libduckdb_sys::DUCKDB_TYPE_DUCKDB_TYPE_TIMESTAMP,
);Sourcepub const fn try_from_duckdb_type(raw: DUCKDB_TYPE) -> Option<Self>
pub const fn try_from_duckdb_type(raw: DUCKDB_TYPE) -> Option<Self>
Converts a raw DUCKDB_TYPE constant into a TypeId, or None if the
value is not one this build knows about.
Recognizes every variant available in the active feature set: all the
type-enum values of the DuckDB 1.4.4 floor (TIME_NS, ANY,
BIGNUM/VARINT, SQLNULL, INTEGER_LITERAL and STRING_LITERAL
among them, ungated), plus GEOMETRY and VARIANT when the
duckdb-1-5-3 feature is enabled.
Prefer this over from_duckdb_type inside
DuckDB callbacks. An extension routinely sees type values it was not
built for — a column of a type added in a newer DuckDB, or a GEOMETRY
or VARIANT column reaching an extension compiled without duckdb-1-5-3. Returning None
lets the callback raise a DuckDB error, which a panic cannot: quack-rs
turns a caught panic into an error message, but only when the extension
ships panic = "unwind" — under panic = "abort" the process dies.
§Example
use quack_rs::types::TypeId;
use libduckdb_sys::DUCKDB_TYPE_DUCKDB_TYPE_BIGINT;
assert_eq!(
TypeId::try_from_duckdb_type(DUCKDB_TYPE_DUCKDB_TYPE_BIGINT),
Some(TypeId::BigInt)
);
// A value from a future DuckDB is reported, not fatal.
assert_eq!(TypeId::try_from_duckdb_type(9999), None);Sourcepub const fn from_duckdb_type(raw: DUCKDB_TYPE) -> Self
pub const fn from_duckdb_type(raw: DUCKDB_TYPE) -> Self
Converts a raw DUCKDB_TYPE constant back into a TypeId.
§Panics
Panics if raw does not correspond to any TypeId variant available in
the current feature configuration — for example, GEOMETRY or VARIANT
when the duckdb-1-5-3 feature is disabled, or a future/unknown type value.
Inside a DuckDB callback use
try_from_duckdb_type instead: returning
None lets you raise a proper DuckDB error, whereas a panic is at best
caught and reported by quack-rs, and under panic = "abort" kills the
process outright.
Sourcepub const fn composite_constructor_hint(self) -> Option<&'static str>
pub const fn composite_constructor_hint(self) -> Option<&'static str>
Names the constructor to use for a type id that carries parameters, or
None for a plain primitive.
See is_composite for why these types are special.
§Example
use quack_rs::types::TypeId;
assert_eq!(
TypeId::List.composite_constructor_hint(),
Some("LogicalType::list(element_type)")
);
assert_eq!(TypeId::BigInt.composite_constructor_hint(), None);Sourcepub const fn is_composite(self) -> bool
pub const fn is_composite(self) -> bool
Returns true for the types duckdb_create_logical_type cannot build.
DECIMAL, ENUM, LIST, STRUCT, MAP, ARRAY and UNION all carry
parameters — a width, a member list, a child type — that a bare type id
does not express, so each has its own duckdb_create_*_type constructor.
Passing one of them where a primitive type id is expected yields a
silently invalid type rather than an error, which is why
LogicalType::new and the function
builders reject them up front.
Use composite_constructor_hint to
name the constructor to use instead, and pass the result through the
builders’ param_logical / returns_logical methods.
§Example
use quack_rs::types::TypeId;
assert!(TypeId::Struct.is_composite());
assert!(TypeId::Decimal.is_composite());
assert!(!TypeId::BigInt.is_composite());Trait Implementations§
impl Copy for TypeId
impl Eq for TypeId
Source§impl From<TypeId> for LogicalType
impl From<TypeId> for LogicalType
Source§fn from(type_id: TypeId) -> Self
fn from(type_id: TypeId) -> Self
Creates a LogicalType from a TypeId.
This is equivalent to calling LogicalType::new.