MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / find_bound_expr

Method find_bound_expr

src/expr/src/relation/join_input_mapper.rs:296–311  ·  view source on GitHub ↗

Takes an expression in the global context and looks in `equivalences` for an equivalent expression (also expressed in the global context) that belongs to one or more of the inputs in `bound_inputs` # Examples ``` use mz_repr::{Datum, ReprColumnType, ReprRelationType, ReprScalarType}; use mz_expr::{JoinInputMapper, MirRelationExpr, MirScalarExpr}; // A two-column schema common to each of the thr

(
        &self,
        expr: &C,
        bound_inputs: &[usize],
        equivalences: &[Vec<C>],
    )

Source from the content-addressed store, hash-verified

294 /// );
295 /// ```
296 pub fn find_bound_expr<C: Columns + Clone + Eq>(
297 &self,
298 expr: &C,
299 bound_inputs: &[usize],
300 equivalences: &[Vec<C>],
301 ) -> Option<C> {
302 if let Some(equivalence) = equivalences.iter().find(|equivs| equivs.contains(expr)) {
303 if let Some(bound_expr) = equivalence
304 .iter()
305 .find(|expr| self.lookup_inputs(*expr).all(|i| bound_inputs.contains(&i)))
306 {
307 return Some(bound_expr.clone());
308 }
309 }
310 None
311 }
312
313 /// Try to rewrite `expr` from the global context so that all the
314 /// columns point to the `index`th input by replacing subexpressions with their

Callers 4

create_fromMethod · 0.80
create_fromMethod · 0.80
optimize_order_forMethod · 0.80

Calls 6

allMethod · 0.80
lookup_inputsMethod · 0.80
findMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected