pub enum Expr {
Column(Column),
Value(Value),
Function(Function),
Aggregate(Aggregate),
Struct(Struct),
}
Expand description
A Expr enum inspired by: https://docs.rs/sqlparser/latest/sqlparser/ast/enum.Expr.html and mostly: https://docs.rs/polars/latest/polars/prelude/enum.Expr.html or https://docs.rs/polars-lazy/latest/polars_lazy/dsl/enum.Expr.html
Variants§
Implementations§
source§impl Expr
impl Expr
sourcepub fn gaussian_noise() -> Self
pub fn gaussian_noise() -> Self
Gaussian noise based on Box Muller transform
sourcepub fn add_gaussian_noise(self, sigma: f64) -> Self
pub fn add_gaussian_noise(self, sigma: f64) -> Self
Gaussian noise based on Box Muller transform
source§impl Expr
impl Expr
sourcepub fn reduce_modulo_bijection(&self) -> &Expr
pub fn reduce_modulo_bijection(&self) -> &Expr
Reduce the expression modulo a bijection
sourcepub fn into_column_modulo_bijection(&self) -> Option<Column>
pub fn into_column_modulo_bijection(&self) -> Option<Column>
Some column if it reduces to a column, None else.
sourcepub fn eq_modulo_bijection(&self, expr: &Expr) -> bool
pub fn eq_modulo_bijection(&self, expr: &Expr) -> bool
True if 2 expressions are equal modulo a bijection
source§impl Expr
impl Expr
Implement random expression constructor (same thing but no macro here)
pub fn random(n: usize) -> Expr
pub fn filter_column( name: &str, min: Option<Value>, max: Option<Value>, possible_values: Vec<Value> ) -> Option<Expr>
pub fn and_iter<I: IntoIterator<Item = Expr>>(exprs: I) -> Expr
sourcepub fn filter(
columns: BTreeMap<&str, (Option<Value>, Option<Value>, Vec<Value>)>
) -> Expr
pub fn filter( columns: BTreeMap<&str, (Option<Value>, Option<Value>, Vec<Value>)> ) -> Expr
Returns an Expr
for filtering the columns
§Arguments
columns
:Vec<(column_name, minimal_value, maximal_value, possible_values)>
For example,
filter(vec![("my_col", Value::float(2.), Value::float(10.), vec![])])
≡(my_col > 2.) and (my_col < 10)
filter(vec![("my_col", None, Value::float(10.), vec![Value::integer(1), Value::integer(2), Value::integer(5)])])
≡(my_col < 10.) and (my_col in (1, 2, 5))
filter(vec![("my_col1", None, Value::integer(10), vec![]), ("my_col2", Value::float(1.), None, vec![])])])
≡(my_col1 < 10) and (my_col2 > 1.)
source§impl Expr
impl Expr
pub fn pi() -> Expr
pub fn newid() -> Expr
pub fn current_date() -> Expr
pub fn current_time() -> Expr
pub fn current_timestamp() -> Expr
source§impl Expr
impl Expr
pub fn opposite<E: Into<Expr>>(expr: E) -> Expr
pub fn not<E: Into<Expr>>(expr: E) -> Expr
pub fn exp<E: Into<Expr>>(expr: E) -> Expr
pub fn ln<E: Into<Expr>>(expr: E) -> Expr
pub fn log<E: Into<Expr>>(expr: E) -> Expr
pub fn abs<E: Into<Expr>>(expr: E) -> Expr
pub fn sin<E: Into<Expr>>(expr: E) -> Expr
pub fn cos<E: Into<Expr>>(expr: E) -> Expr
pub fn sqrt<E: Into<Expr>>(expr: E) -> Expr
pub fn md5<E: Into<Expr>>(expr: E) -> Expr
pub fn lower<E: Into<Expr>>(expr: E) -> Expr
pub fn upper<E: Into<Expr>>(expr: E) -> Expr
pub fn char_length<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_text<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_integer<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_float<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_boolean<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_date_time<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_date<E: Into<Expr>>(expr: E) -> Expr
pub fn cast_as_time<E: Into<Expr>>(expr: E) -> Expr
pub fn ceil<E: Into<Expr>>(expr: E) -> Expr
pub fn floor<E: Into<Expr>>(expr: E) -> Expr
pub fn sign<E: Into<Expr>>(expr: E) -> Expr
pub fn unhex<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_year<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_month<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_day<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_hour<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_minute<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_second<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_microsecond<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_millisecond<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_dow<E: Into<Expr>>(expr: E) -> Expr
pub fn extract_week<E: Into<Expr>>(expr: E) -> Expr
pub fn dayname<E: Into<Expr>>(expr: E) -> Expr
pub fn quarter<E: Into<Expr>>(expr: E) -> Expr
pub fn date<E: Into<Expr>>(expr: E) -> Expr
pub fn unix_timestamp<E: Into<Expr>>(expr: E) -> Expr
pub fn is_null<E: Into<Expr>>(expr: E) -> Expr
source§impl Expr
impl Expr
pub fn plus<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn minus<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn multiply<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn modulo<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn string_concat<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn gt<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn lt<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn gt_eq<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn lt_eq<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn eq<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn not_eq<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn and<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn or<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn xor<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn bitwise_or<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn bitwise_and<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn bitwise_xor<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn pow<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn position<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn in_list<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn least<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn greatest<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn coalesce<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn rtrim<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn ltrim<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn substr<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn trunc<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn round<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn regexp_contains<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn encode<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn decode<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn date_format<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn from_unixtime<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn like<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn ilike<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn choose<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
pub fn is_bool<L: Into<Expr>, R: Into<Expr>>(left: L, right: R) -> Expr
source§impl Expr
impl Expr
pub fn case<F: Into<Expr>, S: Into<Expr>, T: Into<Expr>>( first: F, second: S, third: T ) -> Expr
pub fn substr_with_size<F: Into<Expr>, S: Into<Expr>, T: Into<Expr>>( first: F, second: S, third: T ) -> Expr
pub fn regexp_replace<F: Into<Expr>, S: Into<Expr>, T: Into<Expr>>( first: F, second: S, third: T ) -> Expr
pub fn datetime_diff<F: Into<Expr>, S: Into<Expr>, T: Into<Expr>>( first: F, second: S, third: T ) -> Expr
source§impl Expr
impl Expr
pub fn first<E: Into<Expr>>(expr: E) -> Expr
pub fn last<E: Into<Expr>>(expr: E) -> Expr
pub fn min<E: Into<Expr>>(expr: E) -> Expr
pub fn max<E: Into<Expr>>(expr: E) -> Expr
pub fn count<E: Into<Expr>>(expr: E) -> Expr
pub fn mean<E: Into<Expr>>(expr: E) -> Expr
pub fn sum<E: Into<Expr>>(expr: E) -> Expr
pub fn var<E: Into<Expr>>(expr: E) -> Expr
pub fn std<E: Into<Expr>>(expr: E) -> Expr
pub fn count_distinct<E: Into<Expr>>(expr: E) -> Expr
pub fn mean_distinct<E: Into<Expr>>(expr: E) -> Expr
pub fn sum_distinct<E: Into<Expr>>(expr: E) -> Expr
pub fn var_distinct<E: Into<Expr>>(expr: E) -> Expr
pub fn std_distinct<E: Into<Expr>>(expr: E) -> Expr
source§impl Expr
impl Expr
Basic constructors They are short because they are supposed to be the primary API for the module
pub fn col<S: Into<String>>(field: S) -> Expr
pub fn qcol<S: Into<String>>(relation: S, field: S) -> Expr
pub fn val<V: Into<Value>>(value: V) -> Expr
pub fn list<L: IntoIterator<Item = V>, V: Into<Value>>(values: L) -> Expr
pub fn structured<S: Clone + Into<String>, E: Clone + Into<Arc<Expr>>, F: AsRef<[(S, E)]>>( fields: F ) -> Expr
pub fn all<F: IntoIterator<Item = Expr>>(factors: F) -> Expr
source§impl Expr
impl Expr
sourcepub fn replace(&self, map: Vec<(Expr, Expr)>) -> (Expr, Vec<(Expr, Expr)>)
pub fn replace(&self, map: Vec<(Expr, Expr)>) -> (Expr, Vec<(Expr, Expr)>)
Replace matched left expressions by corresponding right expressions
sourcepub fn alias(
&self,
named_exprs: Vec<(String, Expr)>
) -> (Expr, Vec<(String, Expr)>)
pub fn alias( &self, named_exprs: Vec<(String, Expr)> ) -> (Expr, Vec<(String, Expr)>)
Alias expressions by name
sourcepub fn into_aggregate(self) -> Expr
pub fn into_aggregate(self) -> Expr
Transform an expression into an aggregation
Trait Implementations§
source§impl<'a> Acceptor<'a> for Expr
impl<'a> Acceptor<'a> for Expr
Implement the Acceptor trait
source§fn dependencies(&'a self) -> Dependencies<'a, Self>
fn dependencies(&'a self) -> Dependencies<'a, Self>
fn accept<O: Clone, V: Visitor<'a, Self, O>>(&'a self, visitor: V) -> O
fn iter(&'a self) -> Iter<'a, Self>
fn iter_with<O: Clone, V: Visitor<'a, Self, O>>( &'a self, visitor: V ) -> IterWith<'a, O, Self, V>
source§impl And<Expr> for Reduce
impl And<Expr> for Reduce
Propagate expr columns into the Reduce and return the modified expression
source§impl From<AggregateColumn> for Expr
impl From<AggregateColumn> for Expr
source§fn from(value: AggregateColumn) -> Self
fn from(value: AggregateColumn) -> Self
source§impl From<Identifier> for Expr
impl From<Identifier> for Expr
source§impl Function for Expr
impl Function for Expr
source§impl<'a> IntoIterator for &'a Expr
impl<'a> IntoIterator for &'a Expr
source§impl PartialEq for Expr
impl PartialEq for Expr
source§impl<'a> TryFrom<&'a Expr> for Expr
impl<'a> TryFrom<&'a Expr> for Expr
Based on the TryIntoExprVisitor implement the TryFrom trait
source§impl TryFrom<Expr> for AggregateColumn
impl TryFrom<Expr> for AggregateColumn
source§impl<'a> TryFrom<WithContext<&'a Expr, &'a Hierarchy<Identifier>>> for Expr
impl<'a> TryFrom<WithContext<&'a Expr, &'a Hierarchy<Identifier>>> for Expr
Based on the TryIntoExprVisitor implement the TryFrom trait
source§impl<'a> Visitor<'a, Expr> for RenameVisitor<'a>
impl<'a> Visitor<'a, Expr> for RenameVisitor<'a>
fn column(&self, column: &'a Column) -> Expr
fn value(&self, value: &'a Value) -> Expr
fn function(&self, function: &'a Function, arguments: Vec<Expr>) -> Expr
fn aggregate(&self, aggregate: &'a Aggregate, argument: Expr) -> Expr
fn structured(&self, fields: Vec<(Identifier, Expr)>) -> Expr
source§impl<'a> Visitor<'a, Expr, (Expr, Vec<(Expr, Expr)>)> for ReplaceVisitor
impl<'a> Visitor<'a, Expr, (Expr, Vec<(Expr, Expr)>)> for ReplaceVisitor
source§fn visit(
&self,
acceptor: &'a Expr,
dependencies: Visited<'a, Expr, (Expr, Vec<(Expr, Expr)>)>
) -> (Expr, Vec<(Expr, Expr)>)
fn visit( &self, acceptor: &'a Expr, dependencies: Visited<'a, Expr, (Expr, Vec<(Expr, Expr)>)> ) -> (Expr, Vec<(Expr, Expr)>)
source§fn dependencies(&self, acceptor: &'a A) -> Dependencies<'a, A>
fn dependencies(&self, acceptor: &'a A) -> Dependencies<'a, A>
source§impl<RequireInput> With<Expr> for MapBuilder<RequireInput>
impl<RequireInput> With<Expr> for MapBuilder<RequireInput>
source§impl<RequireInput> With<Expr> for ReduceBuilder<RequireInput>
impl<RequireInput> With<Expr> for ReduceBuilder<RequireInput>
impl Eq for Expr
impl StructuralPartialEq for Expr
impl Variant for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl !RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl !UnwindSafe for Expr
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<Fun> DataTyped for Fun
impl<Fun> DataTyped for Fun
source§fn has_data_type(&self, data_type: &DataType) -> bool
fn has_data_type(&self, data_type: &DataType) -> bool
source§fn is_contained_by(&self, data_type: &DataType) -> bool
fn is_contained_by(&self, data_type: &DataType) -> bool
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 moresource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.