@@ -1673,7 +1673,7 @@ impl fmt::Display for Expr {
16731673 write ! ( f, "{data_type}" ) ?;
16741674 write ! ( f, " {value}" )
16751675 }
1676- Expr :: Function ( fun) => write ! ( f , "{fun}" ) ,
1676+ Expr :: Function ( fun) => fun . fmt ( f ) ,
16771677 Expr :: Case {
16781678 operand,
16791679 conditions,
@@ -1884,8 +1884,14 @@ pub enum WindowType {
18841884impl Display for WindowType {
18851885 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
18861886 match self {
1887- WindowType :: WindowSpec ( spec) => write ! ( f, "({})" , spec) ,
1888- WindowType :: NamedWindow ( name) => write ! ( f, "{}" , name) ,
1887+ WindowType :: WindowSpec ( spec) => {
1888+ f. write_str ( "(" ) ?;
1889+ NewLine . fmt ( f) ?;
1890+ Indent ( spec) . fmt ( f) ?;
1891+ NewLine . fmt ( f) ?;
1892+ f. write_str ( ")" )
1893+ }
1894+ WindowType :: NamedWindow ( name) => name. fmt ( f) ,
18891895 }
18901896 }
18911897}
@@ -1913,27 +1919,36 @@ pub struct WindowSpec {
19131919
19141920impl fmt:: Display for WindowSpec {
19151921 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1916- let mut delim = "" ;
1922+ let mut is_first = true ;
19171923 if let Some ( window_name) = & self . window_name {
1918- delim = " " ;
1924+ if !is_first {
1925+ SpaceOrNewline . fmt ( f) ?;
1926+ }
1927+ is_first = false ;
19191928 write ! ( f, "{window_name}" ) ?;
19201929 }
19211930 if !self . partition_by . is_empty ( ) {
1922- f. write_str ( delim) ?;
1923- delim = " " ;
1931+ if !is_first {
1932+ SpaceOrNewline . fmt ( f) ?;
1933+ }
1934+ is_first = false ;
19241935 write ! (
19251936 f,
19261937 "PARTITION BY {}" ,
19271938 display_comma_separated( & self . partition_by)
19281939 ) ?;
19291940 }
19301941 if !self . order_by . is_empty ( ) {
1931- f. write_str ( delim) ?;
1932- delim = " " ;
1942+ if !is_first {
1943+ SpaceOrNewline . fmt ( f) ?;
1944+ }
1945+ is_first = false ;
19331946 write ! ( f, "ORDER BY {}" , display_comma_separated( & self . order_by) ) ?;
19341947 }
19351948 if let Some ( window_frame) = & self . window_frame {
1936- f. write_str ( delim) ?;
1949+ if !is_first {
1950+ SpaceOrNewline . fmt ( f) ?;
1951+ }
19371952 if let Some ( end_bound) = & window_frame. end_bound {
19381953 write ! (
19391954 f,
@@ -7096,7 +7111,8 @@ impl fmt::Display for Function {
70967111 }
70977112
70987113 if let Some ( o) = & self . over {
7099- write ! ( f, " OVER {o}" ) ?;
7114+ f. write_str ( " OVER " ) ?;
7115+ o. fmt ( f) ?;
71007116 }
71017117
71027118 if self . uses_odbc_syntax {
0 commit comments