| 1006 | fields(path.segment = self.name) |
| 1007 | )] |
| 1008 | pub fn optimize( |
| 1009 | &self, |
| 1010 | mut relation: MirRelationExpr, |
| 1011 | ctx: &mut TransformCtx, |
| 1012 | ) -> Result<mz_expr::OptimizedMirRelationExpr, TransformError> { |
| 1013 | let transform_result = self.transform(&mut relation, ctx); |
| 1014 | |
| 1015 | match transform_result { |
| 1016 | Ok(_) => { |
| 1017 | mz_repr::explain::trace_plan(&relation); |
| 1018 | Ok(mz_expr::OptimizedMirRelationExpr(relation)) |
| 1019 | } |
| 1020 | Err(e) => { |
| 1021 | // Without this, the dropping of `relation` (which happens automatically when |
| 1022 | // returning from this function) might run into a stack overflow, see |
| 1023 | // https://github.com/MaterializeInc/database-issues/issues/4043 |
| 1024 | relation.destroy_carefully(); |
| 1025 | error!("Optimizer::optimize(): {}", e); |
| 1026 | Err(e) |
| 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | /// Optimizes the supplied relation expression in place, using available arrangements. |
| 1032 | /// |