@@ -26,6 +26,8 @@ use crate::plans::Exchange;
2626use crate :: plans:: Filter ;
2727use crate :: plans:: Join ;
2828use crate :: plans:: Limit ;
29+ use crate :: plans:: MaterializedCTE ;
30+ use crate :: plans:: MaterializedCTERef ;
2931use crate :: plans:: Mutation ;
3032use crate :: plans:: Operator ;
3133use crate :: plans:: RelOperator ;
@@ -63,6 +65,10 @@ fn to_format_tree<I: IdHumanizer>(id_humanizer: &I, op: &RelOperator) -> FormatT
6365 RelOperator :: ConstantTableScan ( op) => constant_scan_to_format_tree ( id_humanizer, op) ,
6466 RelOperator :: UnionAll ( op) => union_all_to_format_tree ( id_humanizer, op) ,
6567 RelOperator :: Mutation ( op) => merge_into_to_format_tree ( id_humanizer, op) ,
68+ RelOperator :: MaterializedCTE ( op) => materialized_cte_to_format_tree ( op) ,
69+ RelOperator :: MaterializedCTERef ( op) => {
70+ materialized_cte_ref_to_format_tree ( id_humanizer, op)
71+ }
6672 _ => FormatTreeNode :: with_children ( format ! ( "{:?}" , op) , vec ! [ ] ) ,
6773 }
6874}
@@ -501,6 +507,44 @@ fn union_all_to_format_tree<I: IdHumanizer>(id_humanizer: &I, op: &UnionAll) ->
501507 FormatTreeNode :: with_children ( format ! ( "{:?}" , op. rel_op( ) ) , children)
502508}
503509
510+ fn materialized_cte_to_format_tree ( op : & MaterializedCTE ) -> FormatTreeNode {
511+ FormatTreeNode :: with_children ( "MaterializedCTE" . to_string ( ) , vec ! [
512+ FormatTreeNode :: new( format!( "cte_name: {}" , op. cte_name) ) ,
513+ FormatTreeNode :: new( format!( "ref_count: {}" , op. ref_count) ) ,
514+ FormatTreeNode :: new( format!( "channel_size: {:?}" , op. channel_size) ) ,
515+ ] )
516+ }
517+
518+ fn materialized_cte_ref_to_format_tree < I : IdHumanizer > (
519+ id_humanizer : & I ,
520+ op : & MaterializedCTERef ,
521+ ) -> FormatTreeNode {
522+ let output_columns = op
523+ . output_columns
524+ . iter ( )
525+ . map ( |idx| id_humanizer. humanize_column_id ( * idx) )
526+ . join ( ", " ) ;
527+
528+ let column_mapping = op
529+ . column_mapping
530+ . iter ( )
531+ . sorted_by_key ( |( from, to) | ( * * from, * * to) )
532+ . map ( |( from, to) | {
533+ format ! (
534+ "{} -> {}" ,
535+ id_humanizer. humanize_column_id( * from) ,
536+ id_humanizer. humanize_column_id( * to)
537+ )
538+ } )
539+ . join ( ", " ) ;
540+
541+ FormatTreeNode :: with_children ( "MaterializedCTERef" . to_string ( ) , vec ! [
542+ FormatTreeNode :: new( format!( "cte_name: {}" , op. cte_name) ) ,
543+ FormatTreeNode :: new( format!( "output columns: [{}]" , output_columns) ) ,
544+ FormatTreeNode :: new( format!( "column mapping: [{}]" , column_mapping) ) ,
545+ ] )
546+ }
547+
504548fn merge_into_to_format_tree < I : IdHumanizer > (
505549 id_humanizer : & I ,
506550 merge_into : & Mutation ,
0 commit comments