pub enum Value {
Show 17 variants
Boolean(bool),
Int(i32),
LongInt(i64),
Float(OrderedFloat<f32>),
Double(OrderedFloat<f64>),
Date(i32),
Time(i64),
Timestamp(i64),
TimestampTZ(i64),
String(String),
UUID(Uuid),
Fixed(usize, Vec<u8>),
Binary(Vec<u8>),
Decimal(Decimal),
Struct(Struct),
List(Vec<Option<Value>>),
Map(BTreeMap<Value, Option<Value>>),
}
Expand description
Values present in iceberg type
Variants§
Boolean(bool)
0x00 for false, non-zero byte for true
Int(i32)
Stored as 4-byte little-endian
LongInt(i64)
Stored as 8-byte little-endian
Float(OrderedFloat<f32>)
Stored as 4-byte little-endian
Double(OrderedFloat<f64>)
Stored as 8-byte little-endian
Date(i32)
Stores days from the 1970-01-01 in an 4-byte little-endian int
Time(i64)
Stores microseconds from midnight in an 8-byte little-endian long
Timestamp(i64)
Stores microseconds from 1970-01-01 00:00:00.000000 in an 8-byte little-endian long
TimestampTZ(i64)
Stores microseconds from 1970-01-01 00:00:00.000000 in an 8-byte little-endian long
String(String)
UTF-8 bytes (without length)
UUID(Uuid)
16-byte big-endian value
Fixed(usize, Vec<u8>)
Binary value
Binary(Vec<u8>)
Binary value (without length)
Decimal(Decimal)
Stores unscaled value as two’s-complement big-endian binary, using the minimum number of bytes for the value
Struct(Struct)
A struct is a tuple of typed values. Each field in the tuple is named and has an integer id that is unique in the table schema. Each field can be either optional or required, meaning that values can (or cannot) be null. Fields may be any type. Fields may have an optional comment or doc string. Fields can have default values.
List(Vec<Option<Value>>)
A list is a collection of values with some element type. The element field has an integer id that is unique in the table schema. Elements can be either optional or required. Element types may be any type.
Map(BTreeMap<Value, Option<Value>>)
A map is a collection of key-value pairs with a key type and a value type. Both the key field and value field each have an integer id that is unique in the table schema. Map keys are required and map values can be either optional or required. Both map keys and map values may be any type, including nested types.
Implementations§
Source§impl Value
impl Value
Sourcepub fn transform(&self, transform: &Transform) -> Result<Value, Error>
pub fn transform(&self, transform: &Transform) -> Result<Value, Error>
Applies a partition transform to the value
§Arguments
transform
- The partition transform to apply
§Returns
Ok(Value)
- The transformed valueErr(Error)
- If the transform cannot be applied to this value type
Supported transforms include:
- Identity - Returns the value unchanged
- Bucket - Applies a hash function and returns bucket number
- Truncate - Truncates numbers or strings
- Year/Month/Day/Hour - Extracts time components from dates and timestamps
Sourcepub fn try_from_bytes(bytes: &[u8], data_type: &Type) -> Result<Self, Error>
pub fn try_from_bytes(bytes: &[u8], data_type: &Type) -> Result<Self, Error>
Attempts to create a Value from raw bytes according to a specified type
§Arguments
bytes
- The raw byte slice to parsedata_type
- The expected type of the value
§Returns
Ok(Value)
- Successfully parsed value of the specified typeErr(Error)
- If the bytes cannot be parsed as the specified type
§Note
Currently only supports primitive types. Complex types like structs, lists, and maps are not supported and will return an error.
Sourcepub fn try_from_json(
value: JsonValue,
data_type: &Type,
) -> Result<Option<Self>, Error>
pub fn try_from_json( value: JsonValue, data_type: &Type, ) -> Result<Option<Self>, Error>
Attempts to create a Value from a JSON value according to a specified type
§Arguments
value
- The JSON value to parsedata_type
- The expected Iceberg type
§Returns
Ok(Some(Value))
- Successfully parsed value of the specified typeOk(None)
- If the JSON value is nullErr(Error)
- If the JSON value cannot be parsed as the specified type
§Note
Handles all primitive types as well as complex types like structs, lists and maps. For complex types, recursively parses their contents according to their type specifications.
Sourcepub fn cast(self, data_type: &Type) -> Result<Self, Error>
pub fn cast(self, data_type: &Type) -> Result<Self, Error>
Attempts to cast this Value to a different Type
§Arguments
data_type
- The target Type to cast to
§Returns
Ok(Value)
- Successfully cast Value of the target typeErr(Error)
- If the value cannot be cast to the target type
§Note
Currently supports casting between numeric types (Int -> Long, Int -> Date, etc) and temporal types (Long -> Time/Timestamp/TimestampTZ). Returns the original value if the target type matches the current type.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Value
impl Ord for Value
Source§impl PartialOrd for Value
impl PartialOrd for Value
impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more