@@ -742,21 +742,23 @@ impl DisplayAs for AggregateExec {
742
742
t : DisplayFormatType ,
743
743
f : & mut std:: fmt:: Formatter ,
744
744
) -> std:: fmt:: Result {
745
+ let format_expr_with_alias =
746
+ |( e, alias) : & ( Arc < dyn PhysicalExpr > , String ) | -> String {
747
+ let e = e. to_string ( ) ;
748
+ if & e != alias {
749
+ format ! ( "{e} as {alias}" )
750
+ } else {
751
+ e
752
+ }
753
+ } ;
745
754
match t {
746
755
DisplayFormatType :: Default | DisplayFormatType :: Verbose => {
747
756
write ! ( f, "AggregateExec: mode={:?}" , self . mode) ?;
748
757
let g: Vec < String > = if self . group_by . is_single ( ) {
749
758
self . group_by
750
759
. expr
751
760
. iter ( )
752
- . map ( |( e, alias) | {
753
- let e = e. to_string ( ) ;
754
- if & e != alias {
755
- format ! ( "{e} as {alias}" )
756
- } else {
757
- e
758
- }
759
- } )
761
+ . map ( format_expr_with_alias)
760
762
. collect ( )
761
763
} else {
762
764
self . group_by
@@ -768,21 +770,11 @@ impl DisplayAs for AggregateExec {
768
770
. enumerate ( )
769
771
. map ( |( idx, is_null) | {
770
772
if * is_null {
771
- let ( e, alias) = & self . group_by . null_expr [ idx] ;
772
- let e = e. to_string ( ) ;
773
- if & e != alias {
774
- format ! ( "{e} as {alias}" )
775
- } else {
776
- e
777
- }
773
+ format_expr_with_alias (
774
+ & self . group_by . null_expr [ idx] ,
775
+ )
778
776
} else {
779
- let ( e, alias) = & self . group_by . expr [ idx] ;
780
- let e = e. to_string ( ) ;
781
- if & e != alias {
782
- format ! ( "{e} as {alias}" )
783
- } else {
784
- e
785
- }
777
+ format_expr_with_alias ( & self . group_by . expr [ idx] )
786
778
}
787
779
} )
788
780
. collect :: < Vec < String > > ( )
@@ -813,14 +805,7 @@ impl DisplayAs for AggregateExec {
813
805
self . group_by
814
806
. expr
815
807
. iter ( )
816
- . map ( |( e, alias) | {
817
- let e = e. to_string ( ) ;
818
- if & e != alias {
819
- format ! ( "{e} as {alias}" )
820
- } else {
821
- e
822
- }
823
- } )
808
+ . map ( format_expr_with_alias)
824
809
. collect ( )
825
810
} else {
826
811
self . group_by
@@ -832,21 +817,11 @@ impl DisplayAs for AggregateExec {
832
817
. enumerate ( )
833
818
. map ( |( idx, is_null) | {
834
819
if * is_null {
835
- let ( e, alias) = & self . group_by . null_expr [ idx] ;
836
- let e = e. to_string ( ) ;
837
- if & e != alias {
838
- format ! ( "{e} as {alias}" )
839
- } else {
840
- e
841
- }
820
+ format_expr_with_alias (
821
+ & self . group_by . null_expr [ idx] ,
822
+ )
842
823
} else {
843
- let ( e, alias) = & self . group_by . expr [ idx] ;
844
- let e = e. to_string ( ) ;
845
- if & e != alias {
846
- format ! ( "{e} as {alias}" )
847
- } else {
848
- e
849
- }
824
+ format_expr_with_alias ( & self . group_by . expr [ idx] )
850
825
}
851
826
} )
852
827
. collect :: < Vec < String > > ( )
0 commit comments