@@ -39,7 +39,6 @@ use crate::physical_optimizer::optimizer::PhysicalOptimizerRule;
3939use crate :: physical_plan:: coalesce_partitions:: CoalescePartitionsExec ;
4040use crate :: physical_plan:: cross_join:: CrossJoinExec ;
4141use crate :: physical_plan:: explain:: ExplainExec ;
42- use crate :: physical_plan:: expressions;
4342use crate :: physical_plan:: expressions:: {
4443 CaseExpr , Column , GetIndexedFieldExpr , Literal , PhysicalSortExpr ,
4544} ;
@@ -54,6 +53,7 @@ use crate::physical_plan::subquery::SubqueryExec;
5453use crate :: physical_plan:: udf;
5554use crate :: physical_plan:: udtf;
5655use crate :: physical_plan:: windows:: WindowAggExec ;
56+ use crate :: physical_plan:: { expressions, DisplayFormatType } ;
5757use crate :: physical_plan:: { join_utils, Partitioning } ;
5858use crate :: physical_plan:: { AggregateExpr , ExecutionPlan , PhysicalExpr , WindowExpr } ;
5959use crate :: scalar:: ScalarValue ;
@@ -74,6 +74,7 @@ use datafusion_physical_expr::expressions::{any, OuterColumn};
7474use futures:: future:: BoxFuture ;
7575use futures:: { FutureExt , StreamExt , TryStreamExt } ;
7676use log:: { debug, trace} ;
77+ use std:: fmt:: Debug ;
7778use std:: sync:: Arc ;
7879
7980fn create_function_physical_name (
@@ -434,15 +435,45 @@ impl PhysicalPlanner for DefaultPhysicalPlanner {
434435 logical_plan : & LogicalPlan ,
435436 session_state : & SessionState ,
436437 ) -> Result < Arc < dyn ExecutionPlan > > {
437- match self . handle_explain ( logical_plan, session_state) . await ? {
438+ let x = match self . handle_explain ( logical_plan, session_state) . await ? {
438439 Some ( plan) => Ok ( plan) ,
439440 None => {
440441 let plan = self
441442 . create_initial_plan ( logical_plan, session_state)
442443 . await ?;
443444 self . optimize_internal ( plan, session_state, |_, _| { } )
444445 }
446+ } ?;
447+
448+ struct X {
449+ plan : Arc < dyn ExecutionPlan > ,
450+ level : usize ,
451+ }
452+
453+ impl Debug for X {
454+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
455+ for _ in 0 ..self . level {
456+ write ! ( f, " " ) ?;
457+ }
458+ self . plan . fmt_as ( DisplayFormatType :: Default , f) ?;
459+ writeln ! ( f) ?;
460+ for child in self . plan . children ( ) {
461+ let a = X {
462+ plan : Arc :: clone ( & child) ,
463+ level : self . level + 1 ,
464+ } ;
465+ write ! ( f, "{:?}" , a) ?;
466+ }
467+ Ok ( ( ) )
468+ }
445469 }
470+
471+ let a = X {
472+ plan : Arc :: clone ( & x) ,
473+ level : 0 ,
474+ } ;
475+ println ! ( "PHYSICAL PLAN:\n {:?}\n " , a) ;
476+ Ok ( x)
446477 }
447478
448479 /// Create a physical expression from a logical expression
0 commit comments