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

Method extract_non_errors_from_expr

src/expr/src/linear.rs:298–318  ·  view source on GitHub ↗

Extracts an error-free MapFilterProject at the root of the expression. The expression will be modified to extract maps, filters, and projects from the root of the expression, which will be returned as `Self`. The extraction will halt if a Map or Filter containing a literal error is reached. Otherwise, the method will return an identity operator. This method is meant to be used during optimizatio

(expr: &MirRelationExpr)

Source from the content-addressed store, hash-verified

296 /// This method is meant to be used during optimization, where it is
297 /// necessary to avoid moving around maps and filters with errors.
298 pub fn extract_non_errors_from_expr(expr: &MirRelationExpr) -> (Self, &MirRelationExpr) {
299 match expr {
300 MirRelationExpr::Map { input, scalars }
301 if scalars.iter().all(|s| !s.is_literal_err()) =>
302 {
303 let (mfp, expr) = Self::extract_non_errors_from_expr(input);
304 (mfp.map(scalars.iter().cloned()), expr)
305 }
306 MirRelationExpr::Filter { input, predicates }
307 if predicates.iter().all(|p| !p.is_literal_err()) =>
308 {
309 let (mfp, expr) = Self::extract_non_errors_from_expr(input);
310 (mfp.filter(predicates.iter().cloned()), expr)
311 }
312 MirRelationExpr::Project { input, outputs } => {
313 let (mfp, expr) = Self::extract_non_errors_from_expr(input);
314 (mfp.project(outputs.iter().cloned()), expr)
315 }
316 x => (Self::new(x.arity()), x),
317 }
318 }
319
320 /// Extracts an error-free MapFilterProject at the root of the expression.
321 ///

Callers

nothing calls this directly

Calls 7

allMethod · 0.80
iterMethod · 0.45
is_literal_errMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
projectMethod · 0.45
arityMethod · 0.45

Tested by

no test coverage detected