pub struct CalculatedMeasure { /* private fields */ }Expand description
A calculated measure derived from an expression
Calculated measures are derived from other measures or dimensions using SQL-like expressions. They’re computed at query time using DataFusion’s expression engine.
§Examples
ⓘ
// profit = revenue - cost
let profit = CalculatedMeasure::new(
"profit",
"revenue - cost",
DataType::Float64,
AggFunc::Sum
)?;
// margin = (profit / revenue) * 100
let margin = CalculatedMeasure::new(
"margin",
"(profit / revenue) * 100",
DataType::Float64,
AggFunc::Avg
)?;Implementations§
Source§impl CalculatedMeasure
impl CalculatedMeasure
Sourcepub fn new(
name: impl Into<String>,
expression: impl Into<String>,
data_type: DataType,
default_agg: AggFunc,
) -> Result<Self>
pub fn new( name: impl Into<String>, expression: impl Into<String>, data_type: DataType, default_agg: AggFunc, ) -> Result<Self>
Sourcepub fn expression(&self) -> &str
pub fn expression(&self) -> &str
Get the SQL expression
Sourcepub fn default_agg(&self) -> AggFunc
pub fn default_agg(&self) -> AggFunc
Get the default aggregation function
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Check if the measure is nullable
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_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Builder-style: set description
Sourcepub fn with_format(self, format: impl Into<String>) -> Self
pub fn with_format(self, format: impl Into<String>) -> Self
Builder-style: set format
Trait Implementations§
Source§impl Clone for CalculatedMeasure
impl Clone for CalculatedMeasure
Source§fn clone(&self) -> CalculatedMeasure
fn clone(&self) -> CalculatedMeasure
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 CalculatedMeasure
impl Debug for CalculatedMeasure
Source§impl<'de> Deserialize<'de> for CalculatedMeasure
impl<'de> Deserialize<'de> for CalculatedMeasure
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 CalculatedMeasure
impl PartialEq for CalculatedMeasure
Source§impl Serialize for CalculatedMeasure
impl Serialize for CalculatedMeasure
impl StructuralPartialEq for CalculatedMeasure
Auto Trait Implementations§
impl Freeze for CalculatedMeasure
impl RefUnwindSafe for CalculatedMeasure
impl Send for CalculatedMeasure
impl Sync for CalculatedMeasure
impl Unpin for CalculatedMeasure
impl UnwindSafe for CalculatedMeasure
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