@@ -38,7 +38,39 @@ pub enum DisplayFormatType {
38
38
Verbose ,
39
39
}
40
40
41
- /// Wraps an `ExecutionPlan` with various ways to display this plan
41
+ /// Wraps an `ExecutionPlan` with various methods for formatting
42
+ ///
43
+ ///
44
+ /// # Example
45
+ /// ```
46
+ /// # use std::sync::Arc;
47
+ /// # use arrow_schema::{Field, Schema, DataType};
48
+ /// # use datafusion_expr::Operator;
49
+ /// # use datafusion_physical_expr::expressions::{binary, col, lit};
50
+ /// # use datafusion_physical_plan::{displayable, ExecutionPlan};
51
+ /// # use datafusion_physical_plan::empty::EmptyExec;
52
+ /// # use datafusion_physical_plan::filter::FilterExec;
53
+ /// # let schema = Schema::new(vec![Field::new("i", DataType::Int32, false)]);
54
+ /// # let plan = EmptyExec::new(Arc::new(schema));
55
+ /// # let i = col("i", &plan.schema()).unwrap();
56
+ /// # let predicate = binary(i, Operator::Eq, lit(1), &plan.schema()).unwrap();
57
+ /// # let plan: Arc<dyn ExecutionPlan> = Arc::new(FilterExec::try_new(predicate, Arc::new(plan)).unwrap());
58
+ /// // Get a one line description (Displayable)
59
+ /// let display_plan = displayable(plan.as_ref());
60
+ ///
61
+ /// // you can use the returned objects to format plans
62
+ /// // where you can use `Display` such as format! or println!
63
+ /// assert_eq!(
64
+ /// &format!("The plan is: {}", display_plan.one_line()),
65
+ /// "The plan is: FilterExec: i@0 = 1\n"
66
+ /// );
67
+ /// // You can also print out the plan and its children in indented mode
68
+ /// assert_eq!(display_plan.indent(false).to_string(),
69
+ /// "FilterExec: i@0 = 1\
70
+ /// \n EmptyExec\
71
+ /// \n"
72
+ /// );
73
+ /// ```
42
74
#[ derive( Debug , Clone ) ]
43
75
pub struct DisplayableExecutionPlan < ' a > {
44
76
inner : & ' a dyn ExecutionPlan ,
0 commit comments