Skip to main content

Module variant

Module variant 

Source
Expand description

VariantValue: an owned, engine-neutral representation of SQL VARIANT.

  • Structurally equivalent to the Parquet variant type.
  • Straightforward mapping to both sqllib representations of the Feldera SQL VARIANT.
  • Mutable: new attributes can be added without reencoding the entire binary value.
use std::collections::BTreeMap;
use feldera_types::variant::{VariantDecimal8, VariantValue};

let attributes = VariantValue::Object(BTreeMap::from([
    ("kafka_topic".to_string(), VariantValue::String("events".into())),
    ("kafka_offset".to_string(), VariantValue::Int64(17)),
    ("price".to_string(), VariantValue::Decimal8(VariantDecimal8::try_new(12345, 2)?)),
]));
let VariantValue::Object(fields) = &attributes else {
    unreachable!()
};
assert_eq!(fields["kafka_offset"], VariantValue::Int64(17));

Structs§

VariantDecimal4
A decimal of at most 9 digits, the Parquet variant’s 4-byte decimal.
VariantDecimal8
A decimal of at most 18 digits, the Parquet variant’s 8-byte decimal.
VariantDecimal16
A decimal of at most 38 digits, the Parquet variant’s 16-byte decimal.

Enums§

VariantDecimalError
Error creating a decimal value.
VariantValue
An owned VARIANT value whose types mirror the Parquet variant encoding.