Repository: cloudspannerecosystem/memefish
Pull request #235 (2024-12-19 03:40:17)

Fix  CreateTable `SQL()` format to align with GetDatabaseDdl
This PR fixes `SQL()` format.

- the value of `indentLevel`, because two-space indent is the same as `GetDatabaseDdl` and user-friendly `gcloud spanner databases ddl describe` output.
- `Cluster` and `CreateRowDeletionPolicy` is different format in API. We should align with it.

```
spanner> CREATE TABLE Districts (
           DistrictID INT64,
           CreatedAt TIMESTAMP
         ) PRIMARY KEY (DistrictID),
         ROW DELETION POLICY (OLDER_THAN(CreatedAt, INTERVAL 1 DAY));
Query OK, 0 rows affected (5.15 sec)

spanner> CREATE TABLE Customers (
           DistrictID INT64,
           CustomerID INT64,
           CreatedAt TIMESTAMP
         ) PRIMARY KEY (DistrictID, CustomerID),
         INTERLEAVE IN PARENT Districts ON DELETE CASCADE,
         ROW DELETION POLICY (OLDER_THAN(CreatedAt, INTERVAL 1 DAY));
Query OK, 0 rows affected (5.01 sec)

spanner> SHOW DDLS;

CREATE TABLE Districts (
  DistrictID INT64,
  CreatedAt TIMESTAMP,
) PRIMARY KEY(DistrictID), ROW DELETION POLICY (OLDER_THAN(CreatedAt, INTERVAL 1 DAY));
CREATE TABLE Customers (
  DistrictID INT64,
  CustomerID INT64,
  CreatedAt TIMESTAMP,
) PRIMARY KEY(DistrictID, CustomerID),
  INTERLEAVE IN PARENT Districts ON DELETE CASCADE, ROW DELETION POLICY (OLDER_THAN(CreatedAt, INTERVAL 1 DAY));

Empty set (0.00 sec)
```


Patch:
diff --git a/ast/sql.go b/ast/sql.go
index 2a3fb4a..5cb263f 100644
--- a/ast/sql.go
+++ b/ast/sql.go
@@ -9,7 +9,8 @@ import (
 
 // indentLevel is the whitespace indentation level.
 // Currently, memefish does not perform pretty printing in general, it is only used by CreateTable.
-const indentLevel = 4
+// Note: The two-space indentation is the same as GetDatabaseDdl in an actual Spanner instance.
+const indentLevel = 2
 
 // indent is a whitespace indentation of indentLevel width.
 // You should use this rather than using indentLevel directly.
@@ -820,12 +821,12 @@ func (i *IndexKey) SQL() string {
 }
 
 func (c *Cluster) SQL() string {
-	return ",\nINTERLEAVE IN PARENT " + c.TableName.SQL() +
+	return ",\n" + indent + "INTERLEAVE IN PARENT " + c.TableName.SQL() +
 		strOpt(c.OnDelete != "", " "+string(c.OnDelete))
 }
 
 func (c *CreateRowDeletionPolicy) SQL() string {
-	return ",\n" + c.RowDeletionPolicy.SQL()
+	return ", " + c.RowDeletionPolicy.SQL()
 }
 
 func (r *RowDeletionPolicy) SQL() string {


Test patch:
diff --git a/parse_helpers_test.go b/parse_helpers_test.go
index 90a6abb..490e5ee 100644
--- a/parse_helpers_test.go
+++ b/parse_helpers_test.go
@@ -87,8 +87,8 @@ func ExampleParseDDL() {
 
 	// Output:
 	// CREATE TABLE foo (
-	//     x INT64,
-	//     y INT64
+	//   x INT64,
+	//   y INT64
 	// ) PRIMARY KEY (x)
 }
 
@@ -114,14 +114,14 @@ func ExampleParseDDLs() {
 
 	// Output:
 	// CREATE TABLE foo (
-	//     x INT64,
-	//     y INT64
+	//   x INT64,
+	//   y INT64
 	// ) PRIMARY KEY (x);
 	// CREATE TABLE bar (
-	//     x INT64,
-	//     z INT64
+	//   x INT64,
+	//   z INT64
 	// ) PRIMARY KEY (x, z),
-	// INTERLEAVE IN PARENT foo;
+	//   INTERLEAVE IN PARENT foo;
 }
 
 func ExampleParseDML() {
diff --git a/testdata/result/ddl/create_table.sql.txt b/testdata/result/ddl/create_table.sql.txt
index 5908b4d..4395d0f 100644
--- a/testdata/result/ddl/create_table.sql.txt
+++ b/testdata/result/ddl/create_table.sql.txt
@@ -393,16 +393,16 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL,
-    baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
-    qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
-    quux JSON,
-    corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
-    FOREIGN KEY (foo) REFERENCES t2 (t2key1),
-    FOREIGN KEY (bar) REFERENCES t2 (t2key2) ON DELETE CASCADE,
-    FOREIGN KEY (baz) REFERENCES t2 (t2key3) ON DELETE NO ACTION,
-    CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
-    CHECK (foo > 0),
-    CONSTRAINT cname CHECK (bar > 0)
+  foo INT64,
+  bar FLOAT64 NOT NULL,
+  baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
+  qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
+  quux JSON,
+  corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
+  FOREIGN KEY (foo) REFERENCES t2 (t2key1),
+  FOREIGN KEY (bar) REFERENCES t2 (t2key2) ON DELETE CASCADE,
+  FOREIGN KEY (baz) REFERENCES t2 (t2key3) ON DELETE NO ACTION,
+  CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
+  CHECK (foo > 0),
+  CONSTRAINT cname CHECK (bar > 0)
 ) PRIMARY KEY (foo, bar)
diff --git a/testdata/result/ddl/create_table_cluster.sql.txt b/testdata/result/ddl/create_table_cluster.sql.txt
index 1563ab4..8dc5187 100644
--- a/testdata/result/ddl/create_table_cluster.sql.txt
+++ b/testdata/result/ddl/create_table_cluster.sql.txt
@@ -62,7 +62,7 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64
+  foo INT64,
+  bar INT64
 ) PRIMARY KEY (),
-INTERLEAVE IN PARENT foobar
+  INTERLEAVE IN PARENT foobar
diff --git a/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt b/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt
index b89f742..9339168 100644
--- a/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt
+++ b/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt
@@ -95,9 +95,8 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64,
-    baz TIMESTAMP
+  foo INT64,
+  bar INT64,
+  baz TIMESTAMP
 ) PRIMARY KEY (),
-INTERLEAVE IN PARENT foobar,
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  INTERLEAVE IN PARENT foobar, ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt b/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt
index 76894d0..45ff2fe 100644
--- a/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt
+++ b/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt
@@ -59,6 +59,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64
+  foo INT64
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar ON DELETE NO ACTION
+  INTERLEAVE IN PARENT foobar ON DELETE NO ACTION
diff --git a/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt b/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt
index 4c8d811..e3eeec6 100644
--- a/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt
+++ b/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt
@@ -59,6 +59,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64
+  foo INT64
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar ON DELETE CASCADE
+  INTERLEAVE IN PARENT foobar ON DELETE CASCADE
diff --git a/testdata/result/ddl/create_table_for_format_test.sql.txt b/testdata/result/ddl/create_table_for_format_test.sql.txt
index 2900c38..fe292d4 100644
--- a/testdata/result/ddl/create_table_for_format_test.sql.txt
+++ b/testdata/result/ddl/create_table_for_format_test.sql.txt
@@ -339,15 +339,14 @@ create table if not exists foo (
 
 --- SQL
 CREATE TABLE IF NOT EXISTS foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL,
-    baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
-    qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
-    corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
-    FOREIGN KEY (foo) REFERENCES t2 (t2key1),
-    CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
-    CHECK (foo > 0),
-    CONSTRAINT cname CHECK (bar > 0)
+  foo INT64,
+  bar FLOAT64 NOT NULL,
+  baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
+  qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
+  corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
+  FOREIGN KEY (foo) REFERENCES t2 (t2key1),
+  CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
+  CHECK (foo > 0),
+  CONSTRAINT cname CHECK (bar > 0)
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar,
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  INTERLEAVE IN PARENT foobar, ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/ddl/create_table_fulltext_albums.sql.txt b/testdata/result/ddl/create_table_fulltext_albums.sql.txt
index e119e9a..ff81d4b 100644
--- a/testdata/result/ddl/create_table_fulltext_albums.sql.txt
+++ b/testdata/result/ddl/create_table_fulltext_albums.sql.txt
@@ -180,11 +180,11 @@ CREATE TABLE Albums (
 
 --- SQL
 CREATE TABLE Albums (
-    AlbumId STRING(MAX) NOT NULL,
-    SingerId INT64 NOT NULL,
-    ReleaseTimestamp INT64 NOT NULL,
-    AlbumTitle STRING(MAX),
-    Rating FLOAT64,
-    AlbumTitle_Tokens TOKENLIST AS (TOKENIZE_FULLTEXT(AlbumTitle)) HIDDEN,
-    Rating_Tokens TOKENLIST AS (TOKENIZE_NUMBER(Rating)) HIDDEN
+  AlbumId STRING(MAX) NOT NULL,
+  SingerId INT64 NOT NULL,
+  ReleaseTimestamp INT64 NOT NULL,
+  AlbumTitle STRING(MAX),
+  Rating FLOAT64,
+  AlbumTitle_Tokens TOKENLIST AS (TOKENIZE_FULLTEXT(AlbumTitle)) HIDDEN,
+  Rating_Tokens TOKENLIST AS (TOKENIZE_NUMBER(Rating)) HIDDEN
 ) PRIMARY KEY (AlbumId)
diff --git a/testdata/result/ddl/create_table_if_not_exists.sql.txt b/testdata/result/ddl/create_table_if_not_exists.sql.txt
index 9da7dcf..9afc1dd 100644
--- a/testdata/result/ddl/create_table_if_not_exists.sql.txt
+++ b/testdata/result/ddl/create_table_if_not_exists.sql.txt
@@ -68,6 +68,6 @@ create table if not exists foo (
 
 --- SQL
 CREATE TABLE IF NOT EXISTS foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL
+  foo INT64,
+  bar FLOAT64 NOT NULL
 ) PRIMARY KEY (foo, bar)
diff --git a/testdata/result/ddl/create_table_row_deletion_policy.sql.txt b/testdata/result/ddl/create_table_row_deletion_policy.sql.txt
index 12140d3..69b5328 100644
--- a/testdata/result/ddl/create_table_row_deletion_policy.sql.txt
+++ b/testdata/result/ddl/create_table_row_deletion_policy.sql.txt
@@ -81,8 +81,7 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64,
-    baz TIMESTAMP
-) PRIMARY KEY (),
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  foo INT64,
+  bar INT64,
+  baz TIMESTAMP
+) PRIMARY KEY (), ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/ddl/create_table_synonyms.sql.txt b/testdata/result/ddl/create_table_synonyms.sql.txt
index 53f8a65..e47d2fb 100644
--- a/testdata/result/ddl/create_table_synonyms.sql.txt
+++ b/testdata/result/ddl/create_table_synonyms.sql.txt
@@ -77,7 +77,7 @@ CREATE TABLE Singers (
 
 --- SQL
 CREATE TABLE Singers (
-    SingerId INT64 NOT NULL,
-    SingerName STRING(1024),
-    SYNONYM (Artists)
+  SingerId INT64 NOT NULL,
+  SingerName STRING(1024),
+  SYNONYM (Artists)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt b/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt
index f19a226..56a2bb2 100644
--- a/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt
+++ b/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt
@@ -89,8 +89,8 @@ CREATE TABLE Singers (
 
 --- SQL
 CREATE TABLE Singers (
-    SingerId INT64 NOT NULL,
-    SingerName STRING(1024),
-    SYNONYM (Ignored),
+  SingerId INT64 NOT NULL,
+  SingerName STRING(1024),
+  SYNONYM (Ignored),
 SYNONYM (Artists)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/ddl/create_table_trailing_comma.sql.txt b/testdata/result/ddl/create_table_trailing_comma.sql.txt
index ec470f4..296e88a 100644
--- a/testdata/result/ddl/create_table_trailing_comma.sql.txt
+++ b/testdata/result/ddl/create_table_trailing_comma.sql.txt
@@ -71,6 +71,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64
+  foo INT64,
+  bar INT64
 ) PRIMARY KEY (foo ASC, bar DESC)
diff --git a/testdata/result/ddl/create_table_types.sql.txt b/testdata/result/ddl/create_table_types.sql.txt
index 134b4e4..ca2be2f 100644
--- a/testdata/result/ddl/create_table_types.sql.txt
+++ b/testdata/result/ddl/create_table_types.sql.txt
@@ -286,18 +286,18 @@ create table types (
 
 --- SQL
 CREATE TABLE types (
-    b BOOL,
-    i INT64,
-    f32 FLOAT32,
-    f FLOAT64,
-    d DATE,
-    t TIMESTAMP,
-    s STRING(256),
-    smax STRING(MAX),
-    bs BYTES(256),
-    bsmax BYTES(MAX),
-    ab ARRAY<BOOL>,
-    abs ARRAY<BYTES(MAX)>,
-    p examples.ProtoType,
-    af32vl ARRAY<FLOAT32>(vector_length => 128)
+  b BOOL,
+  i INT64,
+  f32 FLOAT32,
+  f FLOAT64,
+  d DATE,
+  t TIMESTAMP,
+  s STRING(256),
+  smax STRING(MAX),
+  bs BYTES(256),
+  bsmax BYTES(MAX),
+  ab ARRAY<BOOL>,
+  abs ARRAY<BYTES(MAX)>,
+  p examples.ProtoType,
+  af32vl ARRAY<FLOAT32>(vector_length => 128)
 ) PRIMARY KEY (i)
diff --git a/testdata/result/ddl/create_table_with_sequence_function.sql.txt b/testdata/result/ddl/create_table_with_sequence_function.sql.txt
index 8f80ac2..5bc2834 100644
--- a/testdata/result/ddl/create_table_with_sequence_function.sql.txt
+++ b/testdata/result/ddl/create_table_with_sequence_function.sql.txt
@@ -97,7 +97,7 @@ CREATE TABLE foo
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64 DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE foo_sequence)),
-    bar STRING(MAX),
-    id INT64
+  foo INT64 DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE foo_sequence)),
+  bar STRING(MAX),
+  id INT64
 ) PRIMARY KEY (id)
diff --git a/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt b/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt
index 570b3c9..9b2fcb3 100644
--- a/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt
+++ b/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt
@@ -46,5 +46,5 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK)
 
 --- SQL
 CREATE TABLE `ORDER`.`ORDER` (
-    PK INT64
+  PK INT64
 ) PRIMARY KEY (PK)
diff --git a/testdata/result/ddl/named_schemas_create_table.sql.txt b/testdata/result/ddl/named_schemas_create_table.sql.txt
index fa1ad15..2fd1dd3 100644
--- a/testdata/result/ddl/named_schemas_create_table.sql.txt
+++ b/testdata/result/ddl/named_schemas_create_table.sql.txt
@@ -107,8 +107,8 @@ CREATE TABLE sch1.Singers (
 
 --- SQL
 CREATE TABLE sch1.Singers (
-    SingerId INT64 NOT NULL,
-    FirstName STRING(1024),
-    LastName STRING(1024),
-    SingerInfo BYTES(MAX)
+  SingerId INT64 NOT NULL,
+  FirstName STRING(1024),
+  LastName STRING(1024),
+  SingerInfo BYTES(MAX)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt b/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt
index f88321e..351ec82 100644
--- a/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt
+++ b/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt
@@ -137,8 +137,8 @@ CREATE TABLE sch1.ShoppingCarts (
 
 --- SQL
 CREATE TABLE sch1.ShoppingCarts (
-    CartId INT64 NOT NULL,
-    CustomerId INT64 NOT NULL,
-    CustomerName STRING(MAX) NOT NULL,
-    CONSTRAINT FKShoppingCartsCustomers FOREIGN KEY (CustomerId, CustomerName) REFERENCES sch1.Customers (CustomerId, CustomerName) ON DELETE CASCADE
+  CartId INT64 NOT NULL,
+  CustomerId INT64 NOT NULL,
+  CustomerName STRING(MAX) NOT NULL,
+  CONSTRAINT FKShoppingCartsCustomers FOREIGN KEY (CustomerId, CustomerName) REFERENCES sch1.Customers (CustomerId, CustomerName) ON DELETE CASCADE
 ) PRIMARY KEY (CartId)
diff --git a/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt b/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt
index b9fad9b..ecd0d47 100644
--- a/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt
+++ b/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt
@@ -108,8 +108,8 @@ CREATE TABLE sch1.Albums (
 
 --- SQL
 CREATE TABLE sch1.Albums (
-    SingerId INT64 NOT NULL,
-    AlbumId INT64 NOT NULL,
-    AlbumTitle STRING(MAX)
+  SingerId INT64 NOT NULL,
+  AlbumId INT64 NOT NULL,
+  AlbumTitle STRING(MAX)
 ) PRIMARY KEY (SingerId, AlbumId),
-INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE
+  INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE
diff --git a/testdata/result/statement/create_table.sql.txt b/testdata/result/statement/create_table.sql.txt
index 5908b4d..4395d0f 100644
--- a/testdata/result/statement/create_table.sql.txt
+++ b/testdata/result/statement/create_table.sql.txt
@@ -393,16 +393,16 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL,
-    baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
-    qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
-    quux JSON,
-    corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
-    FOREIGN KEY (foo) REFERENCES t2 (t2key1),
-    FOREIGN KEY (bar) REFERENCES t2 (t2key2) ON DELETE CASCADE,
-    FOREIGN KEY (baz) REFERENCES t2 (t2key3) ON DELETE NO ACTION,
-    CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
-    CHECK (foo > 0),
-    CONSTRAINT cname CHECK (bar > 0)
+  foo INT64,
+  bar FLOAT64 NOT NULL,
+  baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
+  qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
+  quux JSON,
+  corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
+  FOREIGN KEY (foo) REFERENCES t2 (t2key1),
+  FOREIGN KEY (bar) REFERENCES t2 (t2key2) ON DELETE CASCADE,
+  FOREIGN KEY (baz) REFERENCES t2 (t2key3) ON DELETE NO ACTION,
+  CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
+  CHECK (foo > 0),
+  CONSTRAINT cname CHECK (bar > 0)
 ) PRIMARY KEY (foo, bar)
diff --git a/testdata/result/statement/create_table_cluster.sql.txt b/testdata/result/statement/create_table_cluster.sql.txt
index 1563ab4..8dc5187 100644
--- a/testdata/result/statement/create_table_cluster.sql.txt
+++ b/testdata/result/statement/create_table_cluster.sql.txt
@@ -62,7 +62,7 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64
+  foo INT64,
+  bar INT64
 ) PRIMARY KEY (),
-INTERLEAVE IN PARENT foobar
+  INTERLEAVE IN PARENT foobar
diff --git a/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt b/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt
index b89f742..9339168 100644
--- a/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt
+++ b/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt
@@ -95,9 +95,8 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64,
-    baz TIMESTAMP
+  foo INT64,
+  bar INT64,
+  baz TIMESTAMP
 ) PRIMARY KEY (),
-INTERLEAVE IN PARENT foobar,
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  INTERLEAVE IN PARENT foobar, ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt b/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt
index 76894d0..45ff2fe 100644
--- a/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt
+++ b/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt
@@ -59,6 +59,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64
+  foo INT64
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar ON DELETE NO ACTION
+  INTERLEAVE IN PARENT foobar ON DELETE NO ACTION
diff --git a/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt b/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt
index 4c8d811..e3eeec6 100644
--- a/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt
+++ b/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt
@@ -59,6 +59,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64
+  foo INT64
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar ON DELETE CASCADE
+  INTERLEAVE IN PARENT foobar ON DELETE CASCADE
diff --git a/testdata/result/statement/create_table_for_format_test.sql.txt b/testdata/result/statement/create_table_for_format_test.sql.txt
index 2900c38..fe292d4 100644
--- a/testdata/result/statement/create_table_for_format_test.sql.txt
+++ b/testdata/result/statement/create_table_for_format_test.sql.txt
@@ -339,15 +339,14 @@ create table if not exists foo (
 
 --- SQL
 CREATE TABLE IF NOT EXISTS foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL,
-    baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
-    qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
-    corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
-    FOREIGN KEY (foo) REFERENCES t2 (t2key1),
-    CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
-    CHECK (foo > 0),
-    CONSTRAINT cname CHECK (bar > 0)
+  foo INT64,
+  bar FLOAT64 NOT NULL,
+  baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
+  qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
+  corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
+  FOREIGN KEY (foo) REFERENCES t2 (t2key1),
+  CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
+  CHECK (foo > 0),
+  CONSTRAINT cname CHECK (bar > 0)
 ) PRIMARY KEY (foo),
-INTERLEAVE IN PARENT foobar,
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  INTERLEAVE IN PARENT foobar, ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/statement/create_table_fulltext_albums.sql.txt b/testdata/result/statement/create_table_fulltext_albums.sql.txt
index e119e9a..ff81d4b 100644
--- a/testdata/result/statement/create_table_fulltext_albums.sql.txt
+++ b/testdata/result/statement/create_table_fulltext_albums.sql.txt
@@ -180,11 +180,11 @@ CREATE TABLE Albums (
 
 --- SQL
 CREATE TABLE Albums (
-    AlbumId STRING(MAX) NOT NULL,
-    SingerId INT64 NOT NULL,
-    ReleaseTimestamp INT64 NOT NULL,
-    AlbumTitle STRING(MAX),
-    Rating FLOAT64,
-    AlbumTitle_Tokens TOKENLIST AS (TOKENIZE_FULLTEXT(AlbumTitle)) HIDDEN,
-    Rating_Tokens TOKENLIST AS (TOKENIZE_NUMBER(Rating)) HIDDEN
+  AlbumId STRING(MAX) NOT NULL,
+  SingerId INT64 NOT NULL,
+  ReleaseTimestamp INT64 NOT NULL,
+  AlbumTitle STRING(MAX),
+  Rating FLOAT64,
+  AlbumTitle_Tokens TOKENLIST AS (TOKENIZE_FULLTEXT(AlbumTitle)) HIDDEN,
+  Rating_Tokens TOKENLIST AS (TOKENIZE_NUMBER(Rating)) HIDDEN
 ) PRIMARY KEY (AlbumId)
diff --git a/testdata/result/statement/create_table_if_not_exists.sql.txt b/testdata/result/statement/create_table_if_not_exists.sql.txt
index 9da7dcf..9afc1dd 100644
--- a/testdata/result/statement/create_table_if_not_exists.sql.txt
+++ b/testdata/result/statement/create_table_if_not_exists.sql.txt
@@ -68,6 +68,6 @@ create table if not exists foo (
 
 --- SQL
 CREATE TABLE IF NOT EXISTS foo (
-    foo INT64,
-    bar FLOAT64 NOT NULL
+  foo INT64,
+  bar FLOAT64 NOT NULL
 ) PRIMARY KEY (foo, bar)
diff --git a/testdata/result/statement/create_table_row_deletion_policy.sql.txt b/testdata/result/statement/create_table_row_deletion_policy.sql.txt
index 12140d3..69b5328 100644
--- a/testdata/result/statement/create_table_row_deletion_policy.sql.txt
+++ b/testdata/result/statement/create_table_row_deletion_policy.sql.txt
@@ -81,8 +81,7 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64,
-    baz TIMESTAMP
-) PRIMARY KEY (),
-ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
+  foo INT64,
+  bar INT64,
+  baz TIMESTAMP
+) PRIMARY KEY (), ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))
diff --git a/testdata/result/statement/create_table_synonyms.sql.txt b/testdata/result/statement/create_table_synonyms.sql.txt
index 53f8a65..e47d2fb 100644
--- a/testdata/result/statement/create_table_synonyms.sql.txt
+++ b/testdata/result/statement/create_table_synonyms.sql.txt
@@ -77,7 +77,7 @@ CREATE TABLE Singers (
 
 --- SQL
 CREATE TABLE Singers (
-    SingerId INT64 NOT NULL,
-    SingerName STRING(1024),
-    SYNONYM (Artists)
+  SingerId INT64 NOT NULL,
+  SingerName STRING(1024),
+  SYNONYM (Artists)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/statement/create_table_synonyms_abnormal.sql.txt b/testdata/result/statement/create_table_synonyms_abnormal.sql.txt
index f19a226..56a2bb2 100644
--- a/testdata/result/statement/create_table_synonyms_abnormal.sql.txt
+++ b/testdata/result/statement/create_table_synonyms_abnormal.sql.txt
@@ -89,8 +89,8 @@ CREATE TABLE Singers (
 
 --- SQL
 CREATE TABLE Singers (
-    SingerId INT64 NOT NULL,
-    SingerName STRING(1024),
-    SYNONYM (Ignored),
+  SingerId INT64 NOT NULL,
+  SingerName STRING(1024),
+  SYNONYM (Ignored),
 SYNONYM (Artists)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/statement/create_table_trailing_comma.sql.txt b/testdata/result/statement/create_table_trailing_comma.sql.txt
index ec470f4..296e88a 100644
--- a/testdata/result/statement/create_table_trailing_comma.sql.txt
+++ b/testdata/result/statement/create_table_trailing_comma.sql.txt
@@ -71,6 +71,6 @@ create table foo (
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64,
-    bar INT64
+  foo INT64,
+  bar INT64
 ) PRIMARY KEY (foo ASC, bar DESC)
diff --git a/testdata/result/statement/create_table_types.sql.txt b/testdata/result/statement/create_table_types.sql.txt
index 134b4e4..ca2be2f 100644
--- a/testdata/result/statement/create_table_types.sql.txt
+++ b/testdata/result/statement/create_table_types.sql.txt
@@ -286,18 +286,18 @@ create table types (
 
 --- SQL
 CREATE TABLE types (
-    b BOOL,
-    i INT64,
-    f32 FLOAT32,
-    f FLOAT64,
-    d DATE,
-    t TIMESTAMP,
-    s STRING(256),
-    smax STRING(MAX),
-    bs BYTES(256),
-    bsmax BYTES(MAX),
-    ab ARRAY<BOOL>,
-    abs ARRAY<BYTES(MAX)>,
-    p examples.ProtoType,
-    af32vl ARRAY<FLOAT32>(vector_length => 128)
+  b BOOL,
+  i INT64,
+  f32 FLOAT32,
+  f FLOAT64,
+  d DATE,
+  t TIMESTAMP,
+  s STRING(256),
+  smax STRING(MAX),
+  bs BYTES(256),
+  bsmax BYTES(MAX),
+  ab ARRAY<BOOL>,
+  abs ARRAY<BYTES(MAX)>,
+  p examples.ProtoType,
+  af32vl ARRAY<FLOAT32>(vector_length => 128)
 ) PRIMARY KEY (i)
diff --git a/testdata/result/statement/create_table_with_sequence_function.sql.txt b/testdata/result/statement/create_table_with_sequence_function.sql.txt
index 8f80ac2..5bc2834 100644
--- a/testdata/result/statement/create_table_with_sequence_function.sql.txt
+++ b/testdata/result/statement/create_table_with_sequence_function.sql.txt
@@ -97,7 +97,7 @@ CREATE TABLE foo
 
 --- SQL
 CREATE TABLE foo (
-    foo INT64 DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE foo_sequence)),
-    bar STRING(MAX),
-    id INT64
+  foo INT64 DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE foo_sequence)),
+  bar STRING(MAX),
+  id INT64
 ) PRIMARY KEY (id)
diff --git a/testdata/result/statement/named_schema_create_table_backquoted.sql.txt b/testdata/result/statement/named_schema_create_table_backquoted.sql.txt
index 570b3c9..9b2fcb3 100644
--- a/testdata/result/statement/named_schema_create_table_backquoted.sql.txt
+++ b/testdata/result/statement/named_schema_create_table_backquoted.sql.txt
@@ -46,5 +46,5 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK)
 
 --- SQL
 CREATE TABLE `ORDER`.`ORDER` (
-    PK INT64
+  PK INT64
 ) PRIMARY KEY (PK)
diff --git a/testdata/result/statement/named_schemas_create_table.sql.txt b/testdata/result/statement/named_schemas_create_table.sql.txt
index fa1ad15..2fd1dd3 100644
--- a/testdata/result/statement/named_schemas_create_table.sql.txt
+++ b/testdata/result/statement/named_schemas_create_table.sql.txt
@@ -107,8 +107,8 @@ CREATE TABLE sch1.Singers (
 
 --- SQL
 CREATE TABLE sch1.Singers (
-    SingerId INT64 NOT NULL,
-    FirstName STRING(1024),
-    LastName STRING(1024),
-    SingerInfo BYTES(MAX)
+  SingerId INT64 NOT NULL,
+  FirstName STRING(1024),
+  LastName STRING(1024),
+  SingerInfo BYTES(MAX)
 ) PRIMARY KEY (SingerId)
diff --git a/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt b/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt
index f88321e..351ec82 100644
--- a/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt
+++ b/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt
@@ -137,8 +137,8 @@ CREATE TABLE sch1.ShoppingCarts (
 
 --- SQL
 CREATE TABLE sch1.ShoppingCarts (
-    CartId INT64 NOT NULL,
-    CustomerId INT64 NOT NULL,
-    CustomerName STRING(MAX) NOT NULL,
-    CONSTRAINT FKShoppingCartsCustomers FOREIGN KEY (CustomerId, CustomerName) REFERENCES sch1.Customers (CustomerId, CustomerName) ON DELETE CASCADE
+  CartId INT64 NOT NULL,
+  CustomerId INT64 NOT NULL,
+  CustomerName STRING(MAX) NOT NULL,
+  CONSTRAINT FKShoppingCartsCustomers FOREIGN KEY (CustomerId, CustomerName) REFERENCES sch1.Customers (CustomerId, CustomerName) ON DELETE CASCADE
 ) PRIMARY KEY (CartId)
diff --git a/testdata/result/statement/named_schemas_create_table_interleave.sql.txt b/testdata/result/statement/named_schemas_create_table_interleave.sql.txt
index b9fad9b..ecd0d47 100644
--- a/testdata/result/statement/named_schemas_create_table_interleave.sql.txt
+++ b/testdata/result/statement/named_schemas_create_table_interleave.sql.txt
@@ -108,8 +108,8 @@ CREATE TABLE sch1.Albums (
 
 --- SQL
 CREATE TABLE sch1.Albums (
-    SingerId INT64 NOT NULL,
-    AlbumId INT64 NOT NULL,
-    AlbumTitle STRING(MAX)
+  SingerId INT64 NOT NULL,
+  AlbumId INT64 NOT NULL,
+  AlbumTitle STRING(MAX)
 ) PRIMARY KEY (SingerId, AlbumId),
-INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE
+  INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE