1919
2020use std:: borrow:: Cow ;
2121use std:: collections:: HashMap ;
22+ use std:: str:: FromStr ;
2223use std:: sync:: Arc ;
2324
2425use crate :: datasource:: file_format:: file_type_to_format;
@@ -87,6 +88,7 @@ use datafusion_physical_optimizer::PhysicalOptimizerRule;
8788use datafusion_physical_plan:: execution_plan:: InvariantLevel ;
8889use datafusion_physical_plan:: placeholder_row:: PlaceholderRowExec ;
8990use datafusion_physical_plan:: unnest:: ListUnnest ;
91+ use datafusion_physical_plan:: DisplayFormatType ;
9092
9193use crate :: schema_equivalence:: schema_satisfied_by;
9294use async_trait:: async_trait;
@@ -1723,6 +1725,7 @@ impl DefaultPhysicalPlanner {
17231725 let mut stringified_plans = vec ! [ ] ;
17241726
17251727 let config = & session_state. config_options ( ) . explain ;
1728+ let explain_format = DisplayFormatType :: from_str ( & config. format ) ?;
17261729
17271730 if !config. physical_plan_only {
17281731 stringified_plans. clone_from ( & e. stringified_plans ) ;
@@ -1742,7 +1745,11 @@ impl DefaultPhysicalPlanner {
17421745 displayable ( input. as_ref ( ) )
17431746 . set_show_statistics ( config. show_statistics )
17441747 . set_show_schema ( config. show_schema )
1745- . to_stringified ( e. verbose , InitialPhysicalPlan ) ,
1748+ . to_stringified (
1749+ e. verbose ,
1750+ InitialPhysicalPlan ,
1751+ explain_format,
1752+ ) ,
17461753 ) ;
17471754
17481755 // Show statistics + schema in verbose output even if not
@@ -1755,6 +1762,7 @@ impl DefaultPhysicalPlanner {
17551762 . to_stringified (
17561763 e. verbose ,
17571764 InitialPhysicalPlanWithStats ,
1765+ explain_format,
17581766 ) ,
17591767 ) ;
17601768 }
@@ -1765,6 +1773,7 @@ impl DefaultPhysicalPlanner {
17651773 . to_stringified (
17661774 e. verbose ,
17671775 InitialPhysicalPlanWithSchema ,
1776+ explain_format,
17681777 ) ,
17691778 ) ;
17701779 }
@@ -1780,7 +1789,11 @@ impl DefaultPhysicalPlanner {
17801789 displayable ( plan)
17811790 . set_show_statistics ( config. show_statistics )
17821791 . set_show_schema ( config. show_schema )
1783- . to_stringified ( e. verbose , plan_type) ,
1792+ . to_stringified (
1793+ e. verbose ,
1794+ plan_type,
1795+ explain_format,
1796+ ) ,
17841797 ) ;
17851798 } ,
17861799 ) ;
@@ -1791,7 +1804,11 @@ impl DefaultPhysicalPlanner {
17911804 displayable ( input. as_ref ( ) )
17921805 . set_show_statistics ( config. show_statistics )
17931806 . set_show_schema ( config. show_schema )
1794- . to_stringified ( e. verbose , FinalPhysicalPlan ) ,
1807+ . to_stringified (
1808+ e. verbose ,
1809+ FinalPhysicalPlan ,
1810+ explain_format,
1811+ ) ,
17951812 ) ;
17961813
17971814 // Show statistics + schema in verbose output even if not
@@ -1804,6 +1821,7 @@ impl DefaultPhysicalPlanner {
18041821 . to_stringified (
18051822 e. verbose ,
18061823 FinalPhysicalPlanWithStats ,
1824+ explain_format,
18071825 ) ,
18081826 ) ;
18091827 }
@@ -1814,6 +1832,7 @@ impl DefaultPhysicalPlanner {
18141832 . to_stringified (
18151833 e. verbose ,
18161834 FinalPhysicalPlanWithSchema ,
1835+ explain_format,
18171836 ) ,
18181837 ) ;
18191838 }
@@ -2720,6 +2739,10 @@ mod tests {
27202739 DisplayFormatType :: Default | DisplayFormatType :: Verbose => {
27212740 write ! ( f, "NoOpExecutionPlan" )
27222741 }
2742+ DisplayFormatType :: TreeRender => {
2743+ // TODO: collect info
2744+ write ! ( f, "" )
2745+ }
27232746 }
27242747 }
27252748 }
0 commit comments