Skip to content

Commit 461102b

Browse files
committed
Improve CREATE LIVE VIEW format
1 parent af5073c commit 461102b

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

parser/format.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,30 +840,30 @@ func (c *CreateLiveView) FormatSQL(formatter *Formatter) {
840840
formatter.WriteExpr(c.Name)
841841

842842
if c.OnCluster != nil {
843-
formatter.WriteByte(whitespace)
843+
formatter.Break()
844844
formatter.WriteExpr(c.OnCluster)
845845
}
846846

847847
if c.WithTimeout != nil {
848-
formatter.WriteByte(whitespace)
848+
formatter.Break()
849849
formatter.WriteExpr(c.WithTimeout)
850850
}
851851

852852
if c.Destination != nil {
853-
formatter.WriteByte(whitespace)
853+
formatter.Break()
854854
formatter.WriteExpr(c.Destination)
855855
}
856856

857857
if c.TableSchema != nil {
858-
formatter.WriteByte(whitespace)
858+
formatter.Break()
859859
formatter.WriteExpr(c.TableSchema)
860860
}
861861

862862
if c.SubQuery != nil {
863-
formatter.WriteString(" AS ")
863+
formatter.Break()
864+
formatter.WriteString("AS ")
864865
formatter.WriteExpr(c.SubQuery)
865866
}
866-
867867
}
868868

869869
func (c *CreateMaterializedView) FormatSQL(formatter *Formatter) {

parser/testdata/ddl/format/beautify/create_live_view_basic.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ AS SELECT id FROM my_table;
55

66

77
-- Beautify SQL:
8-
CREATE LIVE VIEW my_live_view WITH TIMEOUT 10 TO my_destination (
8+
CREATE LIVE VIEW my_live_view
9+
WITH TIMEOUT 10
10+
TO my_destination
11+
(
912
id String
10-
) AS SELECT
13+
)
14+
AS SELECT
1115
id
1216
FROM
1317
my_table;

0 commit comments

Comments
 (0)