pub enum DataType {
Show 20 variants
Boolean,
SmallInt,
Integer,
BigInt,
Float,
Double,
Decimal {
precision: u8,
scale: u8,
},
Varchar {
max_length: Option<u32>,
},
Char {
length: u32,
},
Text,
Blob,
Date,
Time,
Timestamp {
with_timezone: bool,
},
Interval,
Array(Box<DataType>),
Struct(Vec<(String, DataType)>),
Map(Box<DataType>, Box<DataType>),
Null,
Unknown,
}Expand description
SQL data types supported by smelt
This enum represents the logical SQL types. Backend-specific variations (e.g., DuckDB’s HUGEINT) are mapped to these canonical types.
Variants§
Boolean
Boolean (TRUE/FALSE)
SmallInt
Small integer (2 bytes, -32768 to 32767)
Integer
Integer (4 bytes)
BigInt
Big integer (8 bytes)
Float
Single-precision floating point
Double
Double-precision floating point
Decimal
Exact decimal with precision and scale
Varchar
Variable-length string with optional max length
Char
Fixed-length string
Text
Unbounded text
Blob
Binary large object
Date
Calendar date (year, month, day)
Time
Time of day
Timestamp
Timestamp (date + time)
Interval
Time interval
Array(Box<DataType>)
Array of elements
Struct(Vec<(String, DataType)>)
Struct with named fields: STRUCT(a INTEGER, b VARCHAR)
Map(Box<DataType>, Box<DataType>)
Map from key type to value type: MAP(VARCHAR, INTEGER)
Null
NULL literal type
Unknown
Type could not be determined (error recovery)
Implementations§
Source§impl DataType
impl DataType
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Check if this type is numeric (supports arithmetic operations)
Sourcepub fn is_complex(&self) -> bool
pub fn is_complex(&self) -> bool
Check if this type is a complex/nested type (Array, Struct, Map)
Sourcepub fn is_temporal(&self) -> bool
pub fn is_temporal(&self) -> bool
Check if this type is a date/time type
Sourcepub fn normalize(&self) -> DataType
pub fn normalize(&self) -> DataType
Normalize this type to its canonical form for comparison.
Text→Varchar { max_length: None }(canonical string type)- Recursively normalizes Array elements, Struct fields, Map key/value
- All other types are returned as-is
Sourcepub fn to_backend_sql(&self) -> String
pub fn to_backend_sql(&self) -> String
Format as SQL type string for backend compilation.
Translates smelt-internal types to what backends actually support:
Text→"VARCHAR"(backends don’t distinguish Text from VARCHAR)