|
18 | 18 | //! Types for plan display |
19 | 19 |
|
20 | 20 | mod graphviz; |
| 21 | +mod tree; |
21 | 22 | pub use graphviz::*; |
| 23 | +pub use tree::*; |
22 | 24 |
|
23 | 25 | use std::{ |
24 | 26 | fmt::{self, Display, Formatter}, |
@@ -134,3 +136,55 @@ pub trait ToStringifiedPlan { |
134 | 136 | /// Create a stringified plan with the specified type |
135 | 137 | fn to_stringified(&self, plan_type: PlanType) -> StringifiedPlan; |
136 | 138 | } |
| 139 | + |
| 140 | +pub trait DisplayAs { |
| 141 | + /// Format according to `DisplayFormatType`, used when verbose representation looks |
| 142 | + /// different from the default one |
| 143 | + /// |
| 144 | + /// Should not include a newline |
| 145 | + fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> fmt::Result; |
| 146 | +} |
| 147 | + |
| 148 | +pub enum DisplayFormatType { |
| 149 | + /// Default, compact format. Example: `FilterExec: c12 < 10.0` |
| 150 | + /// |
| 151 | + /// This format is designed to provide a detailed textual description |
| 152 | + /// of all parts of the plan. |
| 153 | + Default, |
| 154 | + /// Verbose, showing all available details. |
| 155 | + /// |
| 156 | + /// This form is even more detailed than [`Self::Default`] |
| 157 | + Verbose, |
| 158 | + /// TreeRender, displayed in the `tree` explain type. |
| 159 | + /// |
| 160 | + /// This format is inspired by DuckDB's explain plans. The information |
| 161 | + /// presented should be "user friendly", and contain only the most relevant |
| 162 | + /// information for understanding a plan. It should NOT contain the same level |
| 163 | + /// of detail information as the [`Self::Default`] format. |
| 164 | + /// |
| 165 | + /// In this mode, each line has one of two formats: |
| 166 | + /// |
| 167 | + /// 1. A string without a `=`, which is printed in its own line |
| 168 | + /// |
| 169 | + /// 2. A string with a `=` that is treated as a `key=value pair`. Everything |
| 170 | + /// before the first `=` is treated as the key, and everything after the |
| 171 | + /// first `=` is treated as the value. |
| 172 | + /// |
| 173 | + /// For example, if the output of `TreeRender` is this: |
| 174 | + /// ```text |
| 175 | + /// Parquet |
| 176 | + /// partition_sizes=[1] |
| 177 | + /// ``` |
| 178 | + /// |
| 179 | + /// It is rendered in the center of a box in the following way: |
| 180 | + /// |
| 181 | + /// ```text |
| 182 | + /// ┌───────────────────────────┐ |
| 183 | + /// │ DataSourceExec │ |
| 184 | + /// │ -------------------- │ |
| 185 | + /// │ partition_sizes: [1] │ |
| 186 | + /// │ Parquet │ |
| 187 | + /// └───────────────────────────┘ |
| 188 | + /// ``` |
| 189 | + TreeRender, |
| 190 | +} |
0 commit comments