Trait mz_expr::interpret::Interpreter

source ·
pub trait Interpreter {
    type Summary: Clone + Debug + Sized;

    // Required methods
    fn column(&self, id: usize) -> Self::Summary;
    fn literal(
        &self,
        result: &Result<Row, EvalError>,
        col_type: &ColumnType,
    ) -> Self::Summary;
    fn unmaterializable(&self, func: &UnmaterializableFunc) -> Self::Summary;
    fn unary(&self, func: &UnaryFunc, expr: Self::Summary) -> Self::Summary;
    fn binary(
        &self,
        func: &BinaryFunc,
        left: Self::Summary,
        right: Self::Summary,
    ) -> Self::Summary;
    fn variadic(
        &self,
        func: &VariadicFunc,
        exprs: Vec<Self::Summary>,
    ) -> Self::Summary;
    fn cond(
        &self,
        cond: Self::Summary,
        then: Self::Summary,
        els: Self::Summary,
    ) -> Self::Summary;

    // Provided methods
    fn expr(&self, expr: &MirScalarExpr) -> Self::Summary { ... }
    fn mfp_filter(&self, mfp: &MapFilterProject) -> Self::Summary { ... }
    fn mfp_plan_filter(&self, plan: &MfpPlan) -> Self::Summary { ... }
}
Expand description

Abstract interpretation for MirScalarExpr.

MirScalarExpr::eval implements a “concrete interpreter” for the expression type: given an expression and specific column values as input, it returns a specific value for the output. This could be reimplemented using this trait… but it’s most useful for “abstract” interpretations of the expression, where we generalize about sets of possible inputs and outputs. See Trace and ColumnSpecs for how this can be useful in practice.

Required Associated Types§

Required Methods§

source

fn column(&self, id: usize) -> Self::Summary

A column of the input row.

source

fn literal( &self, result: &Result<Row, EvalError>, col_type: &ColumnType, ) -> Self::Summary

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

source

fn unmaterializable(&self, func: &UnmaterializableFunc) -> Self::Summary

A call to an unmaterializable function.

These functions cannot be evaluated by MirScalarExpr::eval. They must be transformed away by a higher layer.

source

fn unary(&self, func: &UnaryFunc, expr: Self::Summary) -> Self::Summary

A function call that takes one expression as an argument.

source

fn binary( &self, func: &BinaryFunc, left: Self::Summary, right: Self::Summary, ) -> Self::Summary

A function call that takes two expressions as arguments.

source

fn variadic( &self, func: &VariadicFunc, exprs: Vec<Self::Summary>, ) -> Self::Summary

A function call that takes an arbitrary number of arguments.

source

fn cond( &self, cond: Self::Summary, then: Self::Summary, els: Self::Summary, ) -> Self::Summary

Conditionally evaluated expressions.

Provided Methods§

source

fn expr(&self, expr: &MirScalarExpr) -> Self::Summary

Evaluate an entire expression, by delegating to the fine-grained methods on Interpreter.

source

fn mfp_filter(&self, mfp: &MapFilterProject) -> Self::Summary

Specifically, this evaluates the map and filters stages of an MFP: summarize each of the map expressions, then and together all of the filters.

source

fn mfp_plan_filter(&self, plan: &MfpPlan) -> Self::Summary

Similar to Self::mfp_filter, but includes the additional temporal filters that have been broken out.

Implementors§