pub struct VirtualDimension { /* private fields */ }Expand description
A virtual dimension computed from an expression
Virtual dimensions are derived from other dimensions or measures using SQL-like expressions. Common use cases include date part extraction, categorization, and transformations.
§Examples
ⓘ
// Extract year from date
let year = VirtualDimension::new(
"year",
"EXTRACT(YEAR FROM sale_date)",
DataType::Int32
)?;
// Categorize ages
let age_group = VirtualDimension::new(
"age_group",
"CASE WHEN age < 18 THEN 'Minor' WHEN age < 65 THEN 'Adult' ELSE 'Senior' END",
DataType::Utf8
)?;Implementations§
Source§impl VirtualDimension
impl VirtualDimension
Sourcepub fn new(
name: impl Into<String>,
expression: impl Into<String>,
data_type: DataType,
) -> Result<Self>
pub fn new( name: impl Into<String>, expression: impl Into<String>, data_type: DataType, ) -> Result<Self>
Sourcepub fn expression(&self) -> &str
pub fn expression(&self) -> &str
Get the SQL expression
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Check if the dimension is nullable
Sourcepub fn cardinality(&self) -> Option<usize>
pub fn cardinality(&self) -> Option<usize>
Get the cardinality
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Get the description
Sourcepub fn with_nullable(self, nullable: bool) -> Self
pub fn with_nullable(self, nullable: bool) -> Self
Builder-style: set nullable
Sourcepub fn with_cardinality(self, cardinality: usize) -> Self
pub fn with_cardinality(self, cardinality: usize) -> Self
Builder-style: set cardinality
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Builder-style: set description
Trait Implementations§
Source§impl Clone for VirtualDimension
impl Clone for VirtualDimension
Source§fn clone(&self) -> VirtualDimension
fn clone(&self) -> VirtualDimension
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VirtualDimension
impl Debug for VirtualDimension
Source§impl<'de> Deserialize<'de> for VirtualDimension
impl<'de> Deserialize<'de> for VirtualDimension
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for VirtualDimension
impl PartialEq for VirtualDimension
Source§impl Serialize for VirtualDimension
impl Serialize for VirtualDimension
impl StructuralPartialEq for VirtualDimension
Auto Trait Implementations§
impl Freeze for VirtualDimension
impl RefUnwindSafe for VirtualDimension
impl Send for VirtualDimension
impl Sync for VirtualDimension
impl Unpin for VirtualDimension
impl UnwindSafe for VirtualDimension
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
Mutably borrows from an owned value. Read more
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>
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 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>
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