Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nimdeveloper/better-duck/llms.txt
Use this file to discover all available pages before exploring further.
better-duck-diesel organises column types into two categories. The first is the set of standard
Diesel SQL types (Bool, Integer, Text, Timestamp, and so on) — these work out of the box
without any extra import. The second is a set of DuckDB-specific extensions that cover unsigned
integers, oversized integers, timestamps with time zones, composite types, and more. The extension
types live in better_duck_diesel::sql_types and must be brought into scope explicitly when
you use them in a table! definition.
Standard Diesel Types
These types require no additional imports and map directly to common DuckDB column types. Allchrono-mapped Rust types require the chrono feature on better-duck-diesel.
| Diesel SQL type | DuckDB column type | Rust type |
|---|---|---|
Bool | BOOLEAN | bool |
SmallInt | SMALLINT | i16 |
Integer | INTEGER | i32 |
BigInt | BIGINT | i64 |
Float | FLOAT | f32 |
Double | DOUBLE | f64 |
Text | VARCHAR | String |
Binary | BLOB | Vec<u8> |
Date | DATE | chrono::NaiveDate (chrono) |
Time | TIME | chrono::NaiveTime (chrono) |
Timestamp | TIMESTAMP | chrono::NaiveDateTime (chrono) |
Numeric | DECIMAL | rust_decimal::Decimal (decimal) |
Nullable<T> wrapper, for example
Nullable<Integer> maps to Option<i32> in Rust.
DuckDB-Specific Types
Import the extension types with:| Diesel SQL type | DuckDB column type | Rust type |
|---|---|---|
DuckTinyInt | TINYINT (INT1) | i8 |
DuckUTinyInt | UTINYINT | u8 |
DuckUSmallInt | USMALLINT | u16 |
DuckUInt | UINTEGER | u32 |
DuckUBigInt | UBIGINT | u64 |
DuckHugeInt | HUGEINT | i128 |
DuckUHugeInt | UHUGEINT | u128 |
DuckTimestamptz | TIMESTAMPTZ | chrono::DateTime<Utc> (chrono) |
DuckInterval | INTERVAL | chrono::Duration (chrono) |
DuckTimeTz | TIME WITH TIME ZONE | better_duck_core::types::date_chrono::TimeTz (chrono) |
DuckTimeNs | TIME_NS | chrono::NaiveTime (chrono) |
DuckEnum | ENUM | String |
DuckList | LIST (variable-length) | Vec<DuckValue> |
DuckArray | ARRAY (fixed-length) | Vec<DuckValue> |
DuckStruct | STRUCT | HashMap<String, DuckValue> |
DuckMap | MAP | HashMap<DuckValue, DuckValue> |
DuckUnion | UNION | Box<DuckValue> (active member) |
DuckUuid | UUID | better_duck_core::types::uuid::DuckUuid |
DuckBit | BIT | better_duck_core::types::bit::DuckBit |
DuckBignum | BIGNUM | better_duck_core::types::bignum::DuckBignum |
DuckValue is from better_duck_core::types::value::DuckValue. For composite types (DuckList,
DuckArray, DuckStruct, DuckMap, DuckUnion) you typically use diesel::sql_query with
QueryableByName rather than the full DSL, because Diesel’s Queryable blanket does not extend to
heterogeneous container types.
Using DuckDB Types in table!
Place both use statements inside the table! block to make the DuckDB-specific names available
alongside the standard ones:
DuckHugeInt and DuckUHugeInt, Diesel’s Queryable blanket does not cover i128/u128.
Use QueryableByName with an explicit #[diesel(sql_type = DuckHugeInt)] attribute instead:
Date/Time Types and the chrono Feature
Date/time types work in two modes depending on whether the
chrono feature is enabled on
better-duck-diesel:-
With
chrono—Datemaps tochrono::NaiveDate,Timetochrono::NaiveTime,Timestamptochrono::NaiveDateTime,DuckTimestamptztochrono::DateTime<Utc>,DuckIntervaltochrono::Duration,DuckTimeTztobetter_duck_core::types::date_chrono::TimeTz, andDuckTimeNstochrono::NaiveTime. -
Without
chrono— all date/time types map to plain structs frombetter_duck_core::types::date_native(DuckDate,DuckTime,DuckTimestamp, and so on) andstd::time::Durationfor intervals.
chrono if your application
already depends on the chrono crate to avoid maintaining two separate date/time representations.