(
&'a mut self,
context: &'a ExplainContext<'a>,
)
| 41 | |
| 42 | impl<'a> HirRelationExpr { |
| 43 | fn as_explain_single_plan( |
| 44 | &'a mut self, |
| 45 | context: &'a ExplainContext<'a>, |
| 46 | ) -> Result<ExplainSinglePlan<'a, HirRelationExpr>, ExplainError> { |
| 47 | // unless raw plans are explicitly requested |
| 48 | // ensure that all nested subqueries are wrapped in Let blocks by calling |
| 49 | // `normalize_subqueries` |
| 50 | if !context.config.raw_plans { |
| 51 | mz_ore::panic::catch_unwind_str(AssertUnwindSafe(|| { |
| 52 | normalize_subqueries(self); |
| 53 | Ok(()) |
| 54 | })) |
| 55 | .unwrap_or_else(|panic| { |
| 56 | // A panic during optimization is always a bug; log an error so we learn about it. |
| 57 | // TODO(teskje): collect and log a backtrace from the panic site |
| 58 | tracing::error!("caught a panic during `normalize_subqueries`: {panic}"); |
| 59 | |
| 60 | let msg = format!("unexpected panic during `normalize_subqueries`: {panic}"); |
| 61 | Err(ExplainError::UnknownError(msg)) |
| 62 | })? |
| 63 | } |
| 64 | |
| 65 | // TODO: use config values to infer requested |
| 66 | // plan annotations |
| 67 | let plan = AnnotatedPlan { |
| 68 | plan: self, |
| 69 | annotations: Default::default(), |
| 70 | }; |
| 71 | Ok(ExplainSinglePlan { context, plan }) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /// Normalize the way subqueries appear in [`HirScalarExpr::Exists`] |
no test coverage detected