@@ -735,7 +735,7 @@ func (c *CreateDatabase) FormatSQL(formatter *Formatter) {
735735 formatter .WriteExpr (c .OnCluster )
736736 }
737737 if c .Engine != nil {
738- formatter .WriteByte ( whitespace )
738+ formatter .Break ( )
739739 formatter .WriteExpr (c .Engine )
740740 }
741741 if c .Comment != nil {
@@ -844,19 +844,21 @@ func (c *CreateMaterializedView) FormatSQL(formatter *Formatter) {
844844 }
845845 formatter .WriteExpr (c .Name )
846846 if c .OnCluster != nil {
847- formatter .WriteByte ( whitespace )
847+ formatter .Break ( )
848848 formatter .WriteExpr (c .OnCluster )
849849 }
850850 if c .Refresh != nil {
851- formatter .WriteByte ( whitespace )
851+ formatter .Break ( )
852852 formatter .WriteExpr (c .Refresh )
853853 }
854854 if c .RandomizeFor != nil {
855- formatter .WriteString (" RANDOMIZE FOR " )
855+ formatter .Break ()
856+ formatter .WriteString ("RANDOMIZE FOR " )
856857 formatter .WriteExpr (c .RandomizeFor )
857858 }
858859 if c .DependsOn != nil {
859- formatter .WriteString (" DEPENDS ON " )
860+ formatter .Break ()
861+ formatter .WriteString ("DEPENDS ON " )
860862 for i , dep := range c .DependsOn {
861863 if i > 0 {
862864 formatter .WriteString (", " )
@@ -865,48 +867,54 @@ func (c *CreateMaterializedView) FormatSQL(formatter *Formatter) {
865867 }
866868 }
867869 if c .Settings != nil {
868- formatter .WriteByte ( whitespace )
870+ formatter .Break ( )
869871 formatter .WriteExpr (c .Settings )
870872 }
871873 if c .HasAppend {
872- if c .Settings != nil {
873- formatter .Break ()
874- } else {
875- formatter .WriteByte (whitespace )
876- }
874+ formatter .Break ()
877875 formatter .WriteString ("APPEND" )
878876 }
879877 if c .Engine != nil {
878+ formatter .Break ()
880879 formatter .WriteExpr (c .Engine )
881880 }
882881 if c .Destination != nil {
883- formatter .WriteByte ( whitespace )
882+ formatter .Break ( )
884883 formatter .WriteExpr (c .Destination )
885884 if c .Destination .TableSchema != nil {
886- formatter .WriteByte ( whitespace )
885+ formatter .Break ( )
887886 formatter .WriteExpr (c .Destination .TableSchema )
888887 }
889888 }
890889 if c .HasEmpty {
891- formatter .WriteString (" EMPTY" )
890+ formatter .Break ()
891+ formatter .WriteString ("EMPTY" )
892892 }
893893 if c .Definer != nil {
894- formatter .WriteString (" DEFINER = " )
894+ formatter .Break ()
895+ formatter .WriteString ("DEFINER = " )
895896 formatter .WriteExpr (c .Definer )
896897 }
897898 if c .SQLSecurity != "" {
898- formatter .WriteString (" SQL SECURITY " )
899+ formatter .Break ()
900+ formatter .WriteString ("SQL SECURITY " )
899901 formatter .WriteString (c .SQLSecurity )
900902 }
901903 if c .Populate {
902- formatter .WriteString (" POPULATE" )
904+ formatter .Break ()
905+ formatter .WriteString ("POPULATE" )
903906 }
904907 if c .SubQuery != nil {
905- formatter .WriteString (" AS " )
908+ formatter .Break ()
909+ formatter .WriteString ("AS" )
910+ formatter .Indent ()
911+ formatter .Break ()
906912 formatter .WriteExpr (c .SubQuery )
913+ formatter .Dedent ()
907914 }
908915 if c .Comment != nil {
909- formatter .WriteString (" COMMENT " )
916+ formatter .Break ()
917+ formatter .WriteString ("COMMENT " )
910918 formatter .WriteExpr (c .Comment )
911919 }
912920}
@@ -986,6 +994,7 @@ func (c *CreateTable) FormatSQL(formatter *Formatter) {
986994 formatter .WriteExpr (c .TableSchema )
987995 }
988996 if c .Engine != nil {
997+ formatter .Break ()
989998 formatter .WriteExpr (c .Engine )
990999 }
9911000 if c .SubQuery != nil {
@@ -1359,7 +1368,6 @@ func (d *DropUserOrRole) FormatSQL(formatter *Formatter) {
13591368}
13601369
13611370func (e * EngineExpr ) FormatSQL (formatter * Formatter ) {
1362- formatter .Break ()
13631371 formatter .WriteString ("ENGINE = " )
13641372 formatter .WriteString (e .Name )
13651373 if e .Params != nil {
0 commit comments