Skip to main content

TypeId

Enum TypeId 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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,
);
Source

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);
Source

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.

Source

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);
Source

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());
Source

pub const fn sql_name(self) -> &'static str

Returns a human-readable SQL type name for this TypeId.

§Example
use quack_rs::types::TypeId;

assert_eq!(TypeId::BigInt.sql_name(), "BIGINT");
assert_eq!(TypeId::Varchar.sql_name(), "VARCHAR");

Trait Implementations§

Source§

impl Clone for TypeId

Source§

fn clone(&self) -> TypeId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TypeId

Source§

impl Debug for TypeId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TypeId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TypeId

Source§

impl From<TypeId> for LogicalType

Source§

fn from(type_id: TypeId) -> Self

Creates a LogicalType from a TypeId.

This is equivalent to calling LogicalType::new.

Source§

impl Hash for TypeId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TypeId

Source§

fn eq(&self, other: &TypeId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TypeId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.