Enum expr::MirScalarExpr [−][src]
pub enum MirScalarExpr {
Column(usize),
Literal(Result<Row, EvalError>, ColumnType),
CallNullary(NullaryFunc),
CallUnary {
func: UnaryFunc,
expr: Box<MirScalarExpr>,
},
CallBinary {
func: BinaryFunc,
expr1: Box<MirScalarExpr>,
expr2: Box<MirScalarExpr>,
},
CallVariadic {
func: VariadicFunc,
exprs: Vec<MirScalarExpr>,
},
If {
cond: Box<MirScalarExpr>,
then: Box<MirScalarExpr>,
els: Box<MirScalarExpr>,
},
}
Variants
Column(usize)
Tuple Fields
0: usize
A column of the input row
Literal(Result<Row, EvalError>, ColumnType)
A literal value. (Stored as a row, because we can’t own a Datum)
CallNullary(NullaryFunc)
Tuple Fields
0: NullaryFunc
A function call that takes no arguments.
CallUnary
A function call that takes one expression as an argument.
CallBinary
A function call that takes two expressions as arguments.
CallVariadic
A function call that takes an arbitrary number of arguments.
If
Conditionally evaluated expressions.
It is important that then
and els
only be evaluated if
cond
is true or not, respectively. This is the only way
users can guard execution (other logical operator do not
short-circuit) and we need to preserve that.
Implementations
Applies an infallible immutable f
to each child of type MirScalarExpr
.
Deletages to MirScalarExprVisitor::visit_children
.
Applies an infallible mutable f
to each child of type MirScalarExpr
.
Deletages to MirScalarExprVisitor::visit_mut_children
.
Post-order immutable infallible MirScalarExpr
visitor.
Deletages to MirScalarExprVisitor::visit_post
.
Post-order mutable infallible MirScalarExpr
visitor.
Deletages to MirScalarExprVisitor::visit_mut_post
.
A generalization of visit_mut
.
Deletages to MirScalarExprVisitor::visit_mut_pre_post
.
Rewrites column indices with their value in permutation
.
This method is applicable even when permutation
is not a
strict permutation, and it only needs to have entries for
each column referenced in self
.
Rewrites column indices with their value in permutation
.
This method is applicable even when permutation
is not a
strict permutation, and it only needs to have entries for
each column referenced in self
.
If self is a column, return the column index, otherwise None
.
Reduces a complex expression where possible.
Also canonicalizes the expression.
use expr::{BinaryFunc, MirScalarExpr};
use repr::{ColumnType, Datum, RelationType, ScalarType};
let expr_0 = MirScalarExpr::Column(0);
let expr_t = MirScalarExpr::literal_ok(Datum::True, ScalarType::Bool);
let expr_f = MirScalarExpr::literal_ok(Datum::False, ScalarType::Bool);
let mut test =
expr_t
.clone()
.call_binary(expr_f.clone(), BinaryFunc::And)
.if_then_else(expr_0, expr_t.clone());
let input_type = RelationType::new(vec![ScalarType::Int32.nullable(false)]);
test.reduce(&input_type);
assert_eq!(test, expr_t);
Decompose an IsNull expression into a disjunction of simpler expressions.
Assumes that self
is the expression inside of an IsNull.
Returns Some(expressions)
if the outer IsNull is to be
replaced by some other expression.
AND/OR undistribution to apply at each ScalarExpr
.
Transforms (a && b) || (a && c) into a && (b || c)
Transforms (a || b) && (a || c) into a || (b && c)
Collects undistributable terms from X expressions.
If and
, X is AND. If not and
, X is OR.
Removes undistributed terms from AND expressions.
If and
, X is AND. If not and
, X is OR.
Adds any columns that must be non-Null for self
to be non-Null.
pub fn eval<'a>(
&'a self,
datums: &[Datum<'a>],
temp_storage: &'a RowArena
) -> Result<Datum<'a>, EvalError>
True iff the expression contains NullaryFunc::MzLogicalTimestamp
.
Trait Implementations
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
Adds names and types of the fields of the struct or enum to rti
. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for MirScalarExpr
impl Send for MirScalarExpr
impl Sync for MirScalarExpr
impl Unpin for MirScalarExpr
impl UnwindSafe for MirScalarExpr
Blanket Implementations
Mutably borrows from an owned value. Read more
Formats an object with the “alternative” format ({:#}
) and returns it.
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more