Extracts any MapFilterProject at the root of the expression. The expression will be modified to extract any maps, filters, and projections, which will be returned as `Self`. If there are no maps, filters, or projections the method will return an identity operator. The extracted expressions may contain temporal predicates, and one should be careful to apply them blindly.
(expr: &MirRelationExpr)
| 264 | /// The extracted expressions may contain temporal predicates, and one |
| 265 | /// should be careful to apply them blindly. |
| 266 | pub fn extract_from_expression(expr: &MirRelationExpr) -> (Self, &MirRelationExpr) { |
| 267 | // TODO: This could become iterative rather than recursive if |
| 268 | // we were able to fuse MFP operators from below, rather than |
| 269 | // from above. |
| 270 | match expr { |
| 271 | MirRelationExpr::Map { input, scalars } => { |
| 272 | let (mfp, expr) = Self::extract_from_expression(input); |
| 273 | (mfp.map(scalars.iter().cloned()), expr) |
| 274 | } |
| 275 | MirRelationExpr::Filter { input, predicates } => { |
| 276 | let (mfp, expr) = Self::extract_from_expression(input); |
| 277 | (mfp.filter(predicates.iter().cloned()), expr) |
| 278 | } |
| 279 | MirRelationExpr::Project { input, outputs } => { |
| 280 | let (mfp, expr) = Self::extract_from_expression(input); |
| 281 | (mfp.project(outputs.iter().cloned()), expr) |
| 282 | } |
| 283 | // TODO: The recursion is quadratic in the number of Map/Filter/Project operators due to |
| 284 | // this call to `arity()`. |
| 285 | x => (Self::new(x.arity()), x), |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /// Extracts an error-free MapFilterProject at the root of the expression. |
| 290 | /// |