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

Method as_explain_single_plan

src/sql/src/plan/explain.rs:43–72  ·  view source on GitHub ↗
(
        &'a mut self,
        context: &'a ExplainContext<'a>,
    )

Source from the content-addressed store, hash-verified

41
42impl<'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`]

Callers 2

explain_textMethod · 0.45
explain_jsonMethod · 0.45

Calls 2

catch_unwind_strFunction · 0.85
normalize_subqueriesFunction · 0.85

Tested by

no test coverage detected