Enum Value

Source
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

Source

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 value
  • Err(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
Source

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 parse
  • data_type - The expected type of the value
§Returns
  • Ok(Value) - Successfully parsed value of the specified type
  • Err(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.

Source

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 parse
  • data_type - The expected Iceberg type
§Returns
  • Ok(Some(Value)) - Successfully parsed value of the specified type
  • Ok(None) - If the JSON value is null
  • Err(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.

Source

pub fn datatype(&self) -> Type

Returns the Iceberg Type that corresponds to this Value

§Returns
  • The Type (primitive or complex) that matches this Value’s variant
§Note

Currently only implemented for primitive types. Complex types like structs, lists, and maps will cause a panic.

Source

pub fn into_any(self) -> Box<dyn Any>

Converts this Value into a boxed Any trait object

§Returns
  • Box<dyn Any> containing the underlying value
§Note

Currently only implemented for primitive types. Complex types like structs, lists, and maps will panic with unimplemented!()

Source

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 type
  • Err(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 Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Value

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Value> for Value

Source§

fn from(value: &Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for ByteBuf

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl Hash for Value

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Value

Source§

fn cmp(&self, other: &Value) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Value

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TrySub for Value

Source§

fn try_sub(&self, other: &Self) -> Result<Self, Error>

Source§

impl Eq for Value

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T