pub enum DataType {
Show 23 variants
Integer,
Smallint,
Bigint,
Unsigned,
Numeric {
precision: u8,
scale: u8,
},
Decimal {
precision: u8,
scale: u8,
},
Float {
precision: u8,
},
Real,
DoublePrecision,
Character {
length: usize,
},
Varchar {
max_length: Option<usize>,
},
CharacterLargeObject,
Name,
Boolean,
Date,
Time {
with_timezone: bool,
},
Timestamp {
with_timezone: bool,
},
Interval {
start_field: IntervalField,
end_field: Option<IntervalField>,
},
BinaryLargeObject,
Bit {
length: Option<usize>,
},
Vector {
dimensions: u32,
},
UserDefined {
type_name: String,
},
Null,
}Expand description
SQL:1999 Data Types
Represents the type of a column or expression in SQL.
Variants§
Integer
Smallint
Bigint
Unsigned
Numeric
Decimal
Float
Real
DoublePrecision
Character
Varchar
CharacterLargeObject
Name
Boolean
Date
Time
Timestamp
Interval
BinaryLargeObject
Bit
Vector
UserDefined
Null
Implementations§
Source§impl DataType
impl DataType
Sourcepub fn coerce_to_common(&self, other: &DataType) -> Option<DataType>
pub fn coerce_to_common(&self, other: &DataType) -> Option<DataType>
Coerces two types to their common type according to SQL:1999 rules
Returns the result type that should be used when combining values of the two input types, or None if no implicit coercion exists.
Based on SQL:1999 Section 9.5 (Result of data type combinations).
Sourcepub fn is_compatible_with(&self, other: &DataType) -> bool
pub fn is_compatible_with(&self, other: &DataType) -> bool
Check if this type is compatible with another type for operations
This now uses SQL:1999 type coercion rules. Types are compatible if they can be implicitly coerced to a common type.
Sourcepub fn estimated_size_bytes(&self) -> usize
pub fn estimated_size_bytes(&self) -> usize
Returns an estimated size in bytes for values of this type.
This is used for adaptive morsel sizing to maintain cache efficiency. Estimates are conservative (may overestimate) to ensure cache fitting.
Returns the estimated size in bytes for a single value of this type, including any overhead from the SqlValue enum representation.
Sourcepub fn sqlite_affinity(&self) -> TypeAffinity
pub fn sqlite_affinity(&self) -> TypeAffinity
Returns the SQLite type affinity for this data type.
SQLite determines affinity based on the declared type name:
- If the type contains “INT” → INTEGER affinity
- If the type contains “CHAR”, “CLOB”, or “TEXT” → TEXT affinity
- If the type contains “BLOB” or has no type → BLOB/NONE affinity
- If the type contains “REAL”, “FLOA”, or “DOUB” → REAL affinity
- Otherwise → NUMERIC affinity
See: https://www.sqlite.org/datatype3.html#type_affinity