#[non_exhaustive]pub enum Value {
Show 23 variants
Null,
Boolean(bool),
TinyInt(i8),
SmallInt(i16),
Integer(i32),
BigInt(i64),
HugeInt(i128),
UTinyInt(u8),
USmallInt(u16),
UInteger(u32),
UBigInt(u64),
UHugeInt(u128),
Float(f32),
Double(f64),
Decimal {
unscaled: i128,
width: u8,
scale: u8,
},
Varchar(String),
Blob(Vec<u8>),
Date(i32),
Time(i64),
Timestamp(i64),
Interval {
months: i32,
days: i32,
micros: i64,
},
List {
element: LogicalType,
values: Vec<Value>,
},
Struct(Vec<(String, Value)>),
}Expand description
A single SQL value.
PartialEq here is Rust equality and not SQL equality. Two nulls compare equal and two NaNs
compare equal, both of which SQL disagrees with. That is the right behaviour for a test
assertion and the wrong behaviour for a WHERE clause, and the WHERE clause gets its
comparison from the kernels rather than from here.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
NULL, of no particular type.
Boolean(bool)
BOOLEAN.
TinyInt(i8)
TINYINT.
SmallInt(i16)
SMALLINT.
Integer(i32)
INTEGER.
BigInt(i64)
BIGINT.
HugeInt(i128)
HUGEINT.
UTinyInt(u8)
UTINYINT.
USmallInt(u16)
USMALLINT.
UInteger(u32)
UINTEGER.
UBigInt(u64)
UBIGINT.
UHugeInt(u128)
UHUGEINT.
Float(f32)
FLOAT.
Double(f64)
DOUBLE.
Decimal
DECIMAL(width, scale), carrying the unscaled integer.
Fields
Varchar(String)
VARCHAR.
Blob(Vec<u8>)
BLOB.
Date(i32)
DATE, days since 1970-01-01.
Time(i64)
TIME, microseconds since midnight.
Timestamp(i64)
TIMESTAMP, microseconds since 1970-01-01 00:00:00.
Interval
INTERVAL, the months, days and microseconds triple.
Three fields rather than one duration because interval arithmetic with months is not associative with days, and DuckDB’s specific behaviour is what tests assert on. A month is not 30 days and this representation is what refuses to pretend otherwise.
List
A list, carrying its element type so that an empty list still knows what it is empty of.
Struct(Vec<(String, Value)>)
A struct, in field order.
Implementations§
Source§impl Value
impl Value
Sourcepub fn logical_type(&self) -> LogicalType
pub fn logical_type(&self) -> LogicalType
The type of this value.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
The value as an i64, for the integer types that fit in one.
Used by the planner for the places where a literal has to be a small integer, LIMIT and
OFFSET being the obvious ones. Returns None rather than saturating, because a LIMIT
that silently became i64::MAX is worse than an error.