pub enum Expression {
Show 13 variants
Literal(Value),
QuantityLiteral {
value: Decimal,
unit: String,
},
TimeLiteral(String),
IntervalLiteral {
start: String,
end: String,
},
Variable(String),
GroupBy {
variable: String,
collection: Box<Expression>,
filter: Option<Box<Expression>>,
key: Box<Expression>,
condition: Box<Expression>,
},
Binary {
op: BinaryOp,
left: Box<Expression>,
right: Box<Expression>,
},
Unary {
op: UnaryOp,
operand: Box<Expression>,
},
Cast {
operand: Box<Expression>,
target_type: String,
},
Quantifier {
quantifier: Quantifier,
variable: String,
collection: Box<Expression>,
condition: Box<Expression>,
},
MemberAccess {
object: String,
member: String,
},
Aggregation {
function: AggregateFunction,
collection: Box<Expression>,
field: Option<String>,
filter: Option<Box<Expression>>,
},
AggregationComprehension {
function: AggregateFunction,
variable: String,
collection: Box<Expression>,
window: Option<WindowSpec>,
predicate: Box<Expression>,
projection: Box<Expression>,
target_unit: Option<String>,
},
}Variants§
Literal(Value)
QuantityLiteral
TimeLiteral(String)
IntervalLiteral
Variable(String)
GroupBy
Fields
§
collection: Box<Expression>§
filter: Option<Box<Expression>>§
key: Box<Expression>§
condition: Box<Expression>Binary
Unary
Cast
Quantifier
MemberAccess
Aggregation
AggregationComprehension
Fields
§
function: AggregateFunction§
collection: Box<Expression>§
window: Option<WindowSpec>§
predicate: Box<Expression>§
projection: Box<Expression>Implementations§
Source§impl Expression
impl Expression
Sourcepub fn normalize(&self) -> NormalizedExpression
pub fn normalize(&self) -> NormalizedExpression
Returns a canonical normalized form of this expression.
The normalized form applies various simplification rules:
- Identity elimination (
true AND x→x) - Domination (
false AND x→false) - Idempotence (
a AND a→a) - Absorption (
a OR (a AND b)→a) - Double negation (
NOT NOT x→x) - Commutative sorting (operands sorted lexicographically)
Sourcepub fn is_equivalent(&self, other: &Expression) -> bool
pub fn is_equivalent(&self, other: &Expression) -> bool
Returns true if two expressions are semantically equivalent.
Two expressions are equivalent if their normalized forms are identical.
pub fn literal(value: impl Into<Value>) -> Self
pub fn variable(name: &str) -> Self
pub fn binary(op: BinaryOp, left: Expression, right: Expression) -> Self
pub fn unary(op: UnaryOp, operand: Expression) -> Self
pub fn quantifier( q: Quantifier, var: &str, collection: Expression, condition: Expression, ) -> Self
pub fn cast(operand: Expression, target_type: impl Into<String>) -> Self
pub fn comparison( var: &str, op: &str, value: impl Into<Value>, ) -> Result<Self, String>
pub fn aggregation( function: AggregateFunction, collection: Expression, field: Option<impl Into<String>>, filter: Option<Expression>, ) -> Self
pub fn member_access(object: &str, member: &str) -> Self
Source§impl Expression
impl Expression
pub fn expand(&self, graph: &Graph) -> Result<Expression, String>
pub fn substitute(&self, var: &str, value: &Value) -> Result<Expression, String>
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
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 Expression
impl Debug for Expression
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
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 Display for Expression
impl Display for Expression
Source§impl From<&Expression> for Expression
impl From<&Expression> for Expression
Source§fn from(e: &CoreExpression) -> Self
fn from(e: &CoreExpression) -> Self
Converts to this type from the input type.
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl Serialize for Expression
impl Serialize for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
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