pub enum SqlValue {
}Expand description
SQL Values - runtime representation of data
Represents actual values in SQL, including NULL.
String types use StringValue (ArcStr) which provides O(1) cloning.
Strings ≤22 bytes are stored inline (small string optimization) avoiding heap allocation.
Variants§
Integer(i64)
Smallint(i16)
Bigint(i64)
Unsigned(u64)
Numeric(f64)
Float(f32)
Real(f64)
Double(f64)
Character(StringValue)
Varchar(StringValue)
Boolean(bool)
Date(Date)
Time(Time)
Timestamp(Timestamp)
Interval(Interval)
Vector(Vec<f32>)
Blob(Vec<u8>)
Null
Implementations§
Trait Implementations§
Source§impl Hash for SqlValue
Hash implementation for SqlValue
impl Hash for SqlValue
Hash implementation for SqlValue
Custom implementation to handle floating-point values correctly:
- NaN values are treated as equal (hash to same value)
- Uses to_bits() for floats to ensure consistent hashing
- NULL hashes to a specific value
Source§impl Ord for SqlValue
Ord implementation for SqlValue
impl Ord for SqlValue
Ord implementation for SqlValue
Required for BTreeMap usage in indexes for efficient range queries.
For index storage and sorting purposes, we define a total ordering where:
- NULL is treated as “less than” all other values (NULLS FIRST semantics)
- NaNs are treated as “greater than” all other floats for consistency
- Type mismatches use a type-based ordering (e.g., integers < floats < strings)
- Within each type, use natural ordering
Note: This differs from SQL comparison semantics (which uses three-valued logic) but is necessary for BTreeMap keys which require total ordering.
Source§impl PartialEq for SqlValue
PartialEq implementation for SqlValue
impl PartialEq for SqlValue
PartialEq implementation for SqlValue
For DISTINCT operations and BTreeMap keys, we need Eq semantics where:
- NULL == NULL (for grouping purposes, unlike SQL comparison)
- NaN == NaN (for grouping purposes, unlike IEEE 754)
- All other values use standard equality
This is consistent with the Ord implementation and satisfies BTreeMap requirements.
Source§impl PartialOrd for SqlValue
PartialOrd implementation for SQL value comparison
impl PartialOrd for SqlValue
PartialOrd implementation for SQL value comparison
Implements SQL:1999 comparison semantics:
- NULL comparisons return None (SQL UNKNOWN)
- Type mismatches return None (incomparable)
- NaN in floating point returns None (IEEE 754 semantics)
- All other comparisons follow Rust’s natural ordering
Note: This intentionally differs from Ord::cmp which provides total ordering for sorting operations. PartialOrd represents SQL comparison semantics where NULL and type mismatches are incomparable.
impl Eq for SqlValue
Eq implementation for SqlValue
For DISTINCT operations, we need Eq semantics where:
- NULL == NULL (for grouping purposes, unlike SQL comparison)
- NaN == NaN (for grouping purposes, unlike IEEE 754)
- All other values use standard equality