mz_adapter/explain/
fast_path.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! `EXPLAIN` support for [`FastPathPlan`].
11
12use std::collections::BTreeMap;
13
14use mz_expr::explain::{ExplainContext, ExplainMultiPlan};
15use mz_repr::explain::{AnnotatedPlan, Explain, ExplainError, UnsupportedFormat};
16
17use crate::coord::peek::FastPathPlan;
18use crate::explain::Explainable;
19
20impl<'a> Explain<'a> for Explainable<'a, FastPathPlan> {
21    type Context = ExplainContext<'a>;
22
23    type Text = ExplainMultiPlan<'a, FastPathPlan>;
24
25    type Json = ExplainMultiPlan<'a, FastPathPlan>;
26
27    type Dot = UnsupportedFormat;
28
29    fn explain_text(&'a mut self, context: &'a Self::Context) -> Result<Self::Text, ExplainError> {
30        self.as_explain_multi_plan(context)
31    }
32
33    fn explain_json(&'a mut self, context: &'a Self::Context) -> Result<Self::Text, ExplainError> {
34        self.as_explain_multi_plan(context)
35    }
36}
37
38impl<'a> Explainable<'a, FastPathPlan> {
39    fn as_explain_multi_plan(
40        &'a self,
41        context: &'a ExplainContext<'a>,
42    ) -> Result<ExplainMultiPlan<'a, FastPathPlan>, ExplainError> {
43        let plans = vec![(
44            "Explained Query (fast path)".to_string(),
45            AnnotatedPlan {
46                plan: self.0,
47                annotations: BTreeMap::default(),
48            },
49        )];
50
51        let sources = vec![];
52
53        Ok(ExplainMultiPlan {
54            context,
55            sources,
56            plans,
57        })
58    }
59}