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)

Tuple Fields

A literal value. (Stored as a row, because we can’t own a Datum)

CallNullary(NullaryFunc)

Tuple Fields

A function call that takes no arguments.

CallUnary

Fields

func: UnaryFunc

A function call that takes one expression as an argument.

CallBinary

Fields

func: BinaryFunc

A function call that takes two expressions as arguments.

CallVariadic

Fields

A function call that takes an arbitrary number of arguments.

If

Fields

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.

pub fn visit_post<'a, F>(&'a self, f: &mut F) where
    F: FnMut(&'a Self), 

Post-order immutable infallible MirScalarExpr visitor.

Deletages to MirScalarExprVisitor::visit_post.

pub fn visit_mut_post<F>(&mut self, f: &mut F) where
    F: FnMut(&mut Self), 

Post-order mutable infallible MirScalarExpr visitor.

Deletages to MirScalarExprVisitor::visit_mut_post.

pub fn visit_mut_pre_post<F1, F2>(&mut self, pre: &mut F1, post: &mut F2) where
    F1: FnMut(&mut Self) -> Option<Vec<&mut MirScalarExpr>>,
    F2: FnMut(&mut Self), 

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.

Transforms !(a && b) into !a || !b and !(a || b) into !a && !b

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.

True iff the expression contains NullaryFunc::MzLogicalTimestamp.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Adds names and types of the fields of the struct or enum to rti. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

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.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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