@@ -2074,45 +2074,76 @@ impl<'ast> Visitor<'ast> for AstFormatVisitor {
20742074 FormatTreeNode :: with_children ( selection_format_ctx, vec ! [ selection_child] ) ;
20752075 children. push ( selection_node) ;
20762076 }
2077- match & stmt. group_by {
2078- Some ( GroupBy :: Normal ( exprs) ) => {
2079- let mut group_by_list_children = Vec :: with_capacity ( exprs. len ( ) ) ;
2080- for group_by in exprs. iter ( ) {
2081- self . visit_expr ( group_by) ;
2082- group_by_list_children. push ( self . children . pop ( ) . unwrap ( ) ) ;
2077+ if let Some ( group_by) = & stmt. group_by {
2078+ match group_by {
2079+ GroupBy :: Normal ( exprs) => {
2080+ let mut group_by_list_children = Vec :: with_capacity ( exprs. len ( ) ) ;
2081+ for group_by in exprs. iter ( ) {
2082+ self . visit_expr ( group_by) ;
2083+ group_by_list_children. push ( self . children . pop ( ) . unwrap ( ) ) ;
2084+ }
2085+ let group_by_list_name = "GroupByList" . to_string ( ) ;
2086+ let group_by_list_format_ctx = AstFormatContext :: with_children (
2087+ group_by_list_name,
2088+ group_by_list_children. len ( ) ,
2089+ ) ;
2090+ let group_by_list_node = FormatTreeNode :: with_children (
2091+ group_by_list_format_ctx,
2092+ group_by_list_children,
2093+ ) ;
2094+ children. push ( group_by_list_node) ;
20832095 }
2084- let group_by_list_name = "GroupByList" . to_string ( ) ;
2085- let group_by_list_format_ctx = AstFormatContext :: with_children (
2086- group_by_list_name,
2087- group_by_list_children. len ( ) ,
2088- ) ;
2089- let group_by_list_node =
2090- FormatTreeNode :: with_children ( group_by_list_format_ctx, group_by_list_children) ;
2091- children. push ( group_by_list_node) ;
2092- }
2093- Some ( GroupBy :: GroupingSets ( sets) ) => {
2094- let mut grouping_sets = Vec :: with_capacity ( sets. len ( ) ) ;
2095- for set in sets. iter ( ) {
2096- let mut grouping_set = Vec :: with_capacity ( set. len ( ) ) ;
2097- for expr in set. iter ( ) {
2098- self . visit_expr ( expr) ;
2099- grouping_set. push ( self . children . pop ( ) . unwrap ( ) ) ;
2096+ GroupBy :: GroupingSets ( sets) => {
2097+ let mut grouping_sets = Vec :: with_capacity ( sets. len ( ) ) ;
2098+ for set in sets. iter ( ) {
2099+ let mut grouping_set = Vec :: with_capacity ( set. len ( ) ) ;
2100+ for expr in set. iter ( ) {
2101+ self . visit_expr ( expr) ;
2102+ grouping_set. push ( self . children . pop ( ) . unwrap ( ) ) ;
2103+ }
2104+ let name = "GroupingSet" . to_string ( ) ;
2105+ let grouping_set_format_ctx =
2106+ AstFormatContext :: with_children ( name, grouping_set. len ( ) ) ;
2107+ let grouping_set_node =
2108+ FormatTreeNode :: with_children ( grouping_set_format_ctx, grouping_set) ;
2109+ grouping_sets. push ( grouping_set_node) ;
2110+ }
2111+ let group_by_list_name = "GroupByList" . to_string ( ) ;
2112+ let group_by_list_format_ctx =
2113+ AstFormatContext :: with_children ( group_by_list_name, grouping_sets. len ( ) ) ;
2114+ let group_by_list_node =
2115+ FormatTreeNode :: with_children ( group_by_list_format_ctx, grouping_sets) ;
2116+ children. push ( group_by_list_node) ;
2117+ }
2118+ GroupBy :: Rollup ( exprs) => {
2119+ let mut rollup_list_children = Vec :: with_capacity ( exprs. len ( ) ) ;
2120+ for group_by in exprs. iter ( ) {
2121+ self . visit_expr ( group_by) ;
2122+ rollup_list_children. push ( self . children . pop ( ) . unwrap ( ) ) ;
2123+ }
2124+ let rollup_list_name = "GroupByRollUpList" . to_string ( ) ;
2125+ let rollup_list_format_ctx = AstFormatContext :: with_children (
2126+ rollup_list_name,
2127+ rollup_list_children. len ( ) ,
2128+ ) ;
2129+ let rollup_list_node =
2130+ FormatTreeNode :: with_children ( rollup_list_format_ctx, rollup_list_children) ;
2131+ children. push ( rollup_list_node) ;
2132+ }
2133+ GroupBy :: Cube ( exprs) => {
2134+ let mut cube_list_children = Vec :: with_capacity ( exprs. len ( ) ) ;
2135+ for group_by in exprs. iter ( ) {
2136+ self . visit_expr ( group_by) ;
2137+ cube_list_children. push ( self . children . pop ( ) . unwrap ( ) ) ;
21002138 }
2101- let name = "GroupingSet " . to_string ( ) ;
2102- let grouping_set_format_ctx =
2103- AstFormatContext :: with_children ( name , grouping_set . len ( ) ) ;
2104- let grouping_set_node =
2105- FormatTreeNode :: with_children ( grouping_set_format_ctx , grouping_set ) ;
2106- grouping_sets . push ( grouping_set_node ) ;
2139+ let cube_list_name = "GroupByCubeList " . to_string ( ) ;
2140+ let cube_list_format_ctx =
2141+ AstFormatContext :: with_children ( cube_list_name , cube_list_children . len ( ) ) ;
2142+ let cube_list_node =
2143+ FormatTreeNode :: with_children ( cube_list_format_ctx , cube_list_children ) ;
2144+ children . push ( cube_list_node ) ;
21072145 }
2108- let group_by_list_name = "GroupByList" . to_string ( ) ;
2109- let group_by_list_format_ctx =
2110- AstFormatContext :: with_children ( group_by_list_name, grouping_sets. len ( ) ) ;
2111- let group_by_list_node =
2112- FormatTreeNode :: with_children ( group_by_list_format_ctx, grouping_sets) ;
2113- children. push ( group_by_list_node) ;
21142146 }
2115- _ => { }
21162147 }
21172148
21182149 if let Some ( having) = & stmt. having {
0 commit comments