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

Method extract_non_errors_from_expr_mut

src/expr/src/linear.rs:374–400  ·  view source on GitHub ↗

Removes an error-free MapFilterProject from 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, and the expression will remain unchanged. This me

(expr: &mut MirRelationExpr)

Source from the content-addressed store, hash-verified

372 /// This method is meant to be used during optimization, where it is
373 /// necessary to avoid moving around maps and filters with errors.
374 pub fn extract_non_errors_from_expr_mut(expr: &mut MirRelationExpr) -> Self {
375 match expr {
376 MirRelationExpr::Map { input, scalars }
377 if scalars.iter().all(|s| !s.is_literal_err()) =>
378 {
379 let mfp =
380 Self::extract_non_errors_from_expr_mut(input).map(scalars.iter().cloned());
381 *expr = input.take_dangerous();
382 mfp
383 }
384 MirRelationExpr::Filter { input, predicates }
385 if predicates.iter().all(|p| !p.is_literal_err()) =>
386 {
387 let mfp = Self::extract_non_errors_from_expr_mut(input)
388 .filter(predicates.iter().cloned());
389 *expr = input.take_dangerous();
390 mfp
391 }
392 MirRelationExpr::Project { input, outputs } => {
393 let mfp =
394 Self::extract_non_errors_from_expr_mut(input).project(outputs.iter().cloned());
395 *expr = input.take_dangerous();
396 mfp
397 }
398 x => Self::new(x.arity()),
399 }
400 }
401}
402
403impl<E: OptimizableExpr> MapFilterProject<E> {

Callers

nothing calls this directly

Calls 8

allMethod · 0.80
take_dangerousMethod · 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