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 VerboseText = ExplainMultiPlan<'a, FastPathPlan>;
26
27    type Json = ExplainMultiPlan<'a, FastPathPlan>;
28
29    type Dot = UnsupportedFormat;
30
31    fn explain_text(&'a mut self, context: &'a Self::Context) -> Result<Self::Text, ExplainError> {
32        self.as_explain_multi_plan(context)
33    }
34
35    fn explain_verbose_text(
36        &'a mut self,
37        context: &'a Self::Context,
38    ) -> Result<Self::VerboseText, ExplainError> {
39        self.as_explain_multi_plan(context)
40    }
41
42    fn explain_json(&'a mut self, context: &'a Self::Context) -> Result<Self::Text, ExplainError> {
43        self.as_explain_multi_plan(context)
44    }
45}
46
47impl<'a> Explainable<'a, FastPathPlan> {
48    fn as_explain_multi_plan(
49        &'a self,
50        context: &'a ExplainContext<'a>,
51    ) -> Result<ExplainMultiPlan<'a, FastPathPlan>, ExplainError> {
52        let plans = vec![(
53            "Explained Query (fast path)".to_string(),
54            AnnotatedPlan {
55                plan: self.0,
56                annotations: BTreeMap::default(),
57            },
58        )];
59
60        let sources = vec![];
61
62        Ok(ExplainMultiPlan {
63            context,
64            sources,
65            plans,
66        })
67    }
68}