@@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize};
2929#[ cfg( feature = "visitor" ) ]
3030use sqlparser_derive:: { Visit , VisitMut } ;
3131
32- use crate :: display_utils:: { indented_list, Indent , SpaceOrNewline } ;
32+ use crate :: display_utils:: { indented_list, DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
3333
3434pub use super :: ddl:: { ColumnDef , TableConstraint } ;
3535
@@ -267,14 +267,19 @@ impl Display for CreateTable {
267267 write ! ( f, " ON CLUSTER {}" , on_cluster) ?;
268268 }
269269 if !self . columns . is_empty ( ) || !self . constraints . is_empty ( ) {
270- write ! ( f, " ({}" , display_comma_separated( & self . columns) ) ?;
270+ f. write_str ( " (" ) ?;
271+ NewLine . fmt ( f) ?;
272+ Indent ( DisplayCommaSeparated ( & self . columns ) ) . fmt ( f) ?;
271273 if !self . columns . is_empty ( ) && !self . constraints . is_empty ( ) {
272- write ! ( f, ", " ) ?;
274+ f. write_str ( "," ) ?;
275+ SpaceOrNewline . fmt ( f) ?;
273276 }
274- write ! ( f, "{})" , display_comma_separated( & self . constraints) ) ?;
277+ Indent ( DisplayCommaSeparated ( & self . constraints ) ) . fmt ( f) ?;
278+ NewLine . fmt ( f) ?;
279+ f. write_str ( ")" ) ?;
275280 } else if self . query . is_none ( ) && self . like . is_none ( ) && self . clone . is_none ( ) {
276281 // PostgreSQL allows `CREATE TABLE t ();`, but requires empty parens
277- write ! ( f , " ()" ) ?;
282+ f . write_str ( " ()" ) ?;
278283 }
279284
280285 // Hive table comment should be after column definitions, please refer to:
0 commit comments