Repository: AfterShip/clickhouse-sql-parser
Pull request #13 (2023-10-08 02:41:23)

Improve the RENAME statement parser
In #10 , I have only implemented the parsing of rename tables, but the rename syntax also includes `database` and `dictionary`. Their syntax is almost the same, so the `parserRenameTable` will be transformed to improve the rename statement.


Patch:
diff --git a/parser/ast.go b/parser/ast.go
index 36dc0ed..d45df1b 100644
--- a/parser/ast.go
+++ b/parser/ast.go
@@ -3562,29 +3562,31 @@ func (n *UnaryExpr) String(level int) string {
 	return "-" + n.Expr.String(level+1)
 }
 
-type RenameTable struct {
-	RenamePos     Pos
-	StatementEnd  Pos
-	TablePairList []*TablePair
-	OnCluster     *OnClusterExpr
+type RenameStmt struct {
+	RenamePos    Pos
+	StatementEnd Pos
+
+	RenameTarget   string
+	TargetPairList []*TargetPair
+	OnCluster      *OnClusterExpr
 }
 
-func (r *RenameTable) Pos() Pos {
+func (r *RenameStmt) Pos() Pos {
 	return r.RenamePos
 }
 
-func (r *RenameTable) End() Pos {
+func (r *RenameStmt) End() Pos {
 	return r.StatementEnd
 }
 
-func (r *RenameTable) Type() string {
-	return "RENAME TABLE"
+func (r *RenameStmt) Type() string {
+	return "RENAME " + r.RenameTarget
 }
 
-func (r *RenameTable) String(level int) string {
+func (r *RenameStmt) String(level int) string {
 	var builder strings.Builder
-	builder.WriteString("RENAME TABLE ")
-	for i, pair := range r.TablePairList {
+	builder.WriteString("RENAME " + r.RenameTarget + " ")
+	for i, pair := range r.TargetPairList {
 		if i > 0 {
 			builder.WriteString(", ")
 		}
@@ -3599,20 +3601,20 @@ func (r *RenameTable) String(level int) string {
 	return builder.String()
 }
 
-type TablePair struct {
+type TargetPair struct {
 	Old *TableIdentifier
 	New *TableIdentifier
 }
 
-func (t *TablePair) Pos() Pos {
+func (t *TargetPair) Pos() Pos {
 	return t.Old.Pos()
 }
 
-func (t *TablePair) End() Pos {
+func (t *TargetPair) End() Pos {
 	return t.New.End()
 }
 
-func (t *TablePair) String() string {
+func (t *TargetPair) String() string {
 	return t.Old.String(0) + " TO " + t.New.String(0)
 }
 
diff --git a/parser/parser_table.go b/parser/parser_table.go
index 7660f59..46edab5 100644
--- a/parser/parser_table.go
+++ b/parser/parser_table.go
@@ -48,7 +48,7 @@ func (p *Parser) parseDDL(pos Pos) (DDL, error) {
 	case p.matchKeyword(KeywordTruncate):
 		return p.parseTruncateTable(pos)
 	case p.matchKeyword(KeywordRename):
-		return p.parseRenameTable(pos)
+		return p.parseRenameStmt(pos)
 	}
 	return nil, nil // nolint
 }
@@ -1183,31 +1183,42 @@ func (p *Parser) parseInsertExpr(pos Pos) (*InsertExpr, error) {
 	return insertExpr, nil
 }
 
-func (p *Parser) parseRenameTable(pos Pos) (*RenameTable, error) {
+func (p *Parser) parseRenameStmt(pos Pos) (*RenameStmt, error) {
 	if err := p.consumeKeyword(KeywordRename); err != nil {
 		return nil, err
 	}
-	if err := p.consumeKeyword(KeywordTable); err != nil {
-		return nil, err
+
+	renameTarget := KeywordTable
+	switch {
+	case p.tryConsumeKeyword(KeywordDictionary) != nil:
+		renameTarget = KeywordDictionary
+	case p.tryConsumeKeyword(KeywordDatabase) != nil:
+		renameTarget = KeywordDatabase
+	default:
+		if err := p.consumeKeyword(KeywordTable); err != nil {
+			return nil, err
+		}
 	}
 
-	tablePair, err := p.parseTablePair(p.Pos())
+	targetPair, err := p.parseTargetPair(p.Pos())
 	if err != nil {
 		return nil, err
 	}
-	tablePairList := []*TablePair{tablePair}
+	tablePairList := []*TargetPair{targetPair}
 	for p.tryConsumeTokenKind(",") != nil {
-		tablePair, err := p.parseTablePair(p.Pos())
+		tablePair, err := p.parseTargetPair(p.Pos())
 		if err != nil {
 			return nil, err
 		}
 		tablePairList = append(tablePairList, tablePair)
 	}
 
-	renameTable := &RenameTable{
-		RenamePos:     pos,
-		StatementEnd:  tablePairList[len(tablePairList)-1].End(),
-		TablePairList: tablePairList,
+	renameStmt := &RenameStmt{
+		RenamePos:    pos,
+		StatementEnd: tablePairList[len(tablePairList)-1].End(),
+
+		RenameTarget:   renameTarget,
+		TargetPairList: tablePairList,
 	}
 
 	onClusterExpr, err := p.tryParseOnCluster(p.Pos())
@@ -1215,14 +1226,14 @@ func (p *Parser) parseRenameTable(pos Pos) (*RenameTable, error) {
 		return nil, err
 	}
 	if onClusterExpr != nil {
-		renameTable.OnCluster = onClusterExpr
-		renameTable.StatementEnd = onClusterExpr.End()
+		renameStmt.OnCluster = onClusterExpr
+		renameStmt.StatementEnd = onClusterExpr.End()
 	}
 
-	return renameTable, nil
+	return renameStmt, nil
 }
 
-func (p *Parser) parseTablePair(_ Pos) (*TablePair, error) {
+func (p *Parser) parseTargetPair(_ Pos) (*TargetPair, error) {
 	oldTable, err := p.parseTableIdentifier(p.Pos())
 	if err != nil {
 		return nil, err
@@ -1235,7 +1246,7 @@ func (p *Parser) parseTablePair(_ Pos) (*TablePair, error) {
 		return nil, err
 	}
 
-	return &TablePair{
+	return &TargetPair{
 		Old: oldTable,
 		New: newTable,
 	}, nil


Test patch:
diff --git a/parser/testdata/ddl/format/rename.sql b/parser/testdata/ddl/format/rename.sql
new file mode 100644
index 0000000..b8b96ce
--- /dev/null
+++ b/parser/testdata/ddl/format/rename.sql
@@ -0,0 +1,37 @@
+-- Origin SQL:
+-- rename table
+RENAME TABLE t1 TO t11;
+RENAME TABLE t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME TABLE t1 TO t11, t2 TO t22;
+RENAME TABLE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
+-- rename dictionary   
+RENAME DICTIONARY t1 TO t11;
+RENAME DICTIONARY t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME DICTIONARY t1 TO t11, t2 TO t22;
+RENAME DICTIONARY t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
+-- rename database
+RENAME DATABASE t1 TO t11;
+RENAME DATABASE t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME DATABASE t1 TO t11, t2 TO t22;
+RENAME DATABASE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
+
+
+-- Format SQL:
+RENAME TABLE t1 TO t11;
+RENAME TABLE t1 TO t11
+ON CLUSTER 'default_cluster';
+RENAME TABLE t1 TO t11, t2 TO t22;
+RENAME TABLE t1 TO t11, t2 TO t22
+ON CLUSTER 'default_cluster';
+RENAME DICTIONARY t1 TO t11;
+RENAME DICTIONARY t1 TO t11
+ON CLUSTER 'default_cluster';
+RENAME DICTIONARY t1 TO t11, t2 TO t22;
+RENAME DICTIONARY t1 TO t11, t2 TO t22
+ON CLUSTER 'default_cluster';
+RENAME DATABASE t1 TO t11;
+RENAME DATABASE t1 TO t11
+ON CLUSTER 'default_cluster';
+RENAME DATABASE t1 TO t11, t2 TO t22;
+RENAME DATABASE t1 TO t11, t2 TO t22
+ON CLUSTER 'default_cluster';
diff --git a/parser/testdata/ddl/format/rename_table.sql b/parser/testdata/ddl/format/rename_table.sql
deleted file mode 100644
index f7055d2..0000000
--- a/parser/testdata/ddl/format/rename_table.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- Origin SQL:
-RENAME TABLE t1 TO t11;
-RENAME TABLE t1 TO t11 ON CLUSTER 'default_cluster';
-RENAME TABLE t1 TO t11, t2 TO t22;
-RENAME TABLE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
-
-
--- Format SQL:
-RENAME TABLE t1 TO t11;
-RENAME TABLE t1 TO t11
-ON CLUSTER 'default_cluster';
-RENAME TABLE t1 TO t11, t2 TO t22;
-RENAME TABLE t1 TO t11, t2 TO t22
-ON CLUSTER 'default_cluster';
diff --git a/parser/testdata/ddl/output/rename.sql.golden.json b/parser/testdata/ddl/output/rename.sql.golden.json
new file mode 100644
index 0000000..c35fff1
--- /dev/null
+++ b/parser/testdata/ddl/output/rename.sql.golden.json
@@ -0,0 +1,500 @@
+[
+  {
+    "RenamePos": 16,
+    "StatementEnd": 38,
+    "RenameTarget": "TABLE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 29,
+            "NameEnd": 31
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 35,
+            "NameEnd": 38
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 40,
+    "StatementEnd": 90,
+    "RenameTarget": "TABLE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 53,
+            "NameEnd": 55
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 59,
+            "NameEnd": 62
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 63,
+      "Expr": {
+        "LiteralPos": 75,
+        "LiteralEnd": 90,
+        "Literal": "default_cluster"
+      }
+    }
+  },
+  {
+    "RenamePos": 93,
+    "StatementEnd": 126,
+    "RenameTarget": "TABLE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 106,
+            "NameEnd": 108
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 112,
+            "NameEnd": 115
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 117,
+            "NameEnd": 119
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 123,
+            "NameEnd": 126
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 128,
+    "StatementEnd": 189,
+    "RenameTarget": "TABLE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 141,
+            "NameEnd": 143
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 147,
+            "NameEnd": 150
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 152,
+            "NameEnd": 154
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 158,
+            "NameEnd": 161
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 162,
+      "Expr": {
+        "LiteralPos": 174,
+        "LiteralEnd": 189,
+        "Literal": "default_cluster"
+      }
+    }
+  },
+  {
+    "RenamePos": 216,
+    "StatementEnd": 243,
+    "RenameTarget": "DICTIONARY",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 234,
+            "NameEnd": 236
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 240,
+            "NameEnd": 243
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 245,
+    "StatementEnd": 300,
+    "RenameTarget": "DICTIONARY",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 263,
+            "NameEnd": 265
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 269,
+            "NameEnd": 272
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 273,
+      "Expr": {
+        "LiteralPos": 285,
+        "LiteralEnd": 300,
+        "Literal": "default_cluster"
+      }
+    }
+  },
+  {
+    "RenamePos": 303,
+    "StatementEnd": 341,
+    "RenameTarget": "DICTIONARY",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 321,
+            "NameEnd": 323
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 327,
+            "NameEnd": 330
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 332,
+            "NameEnd": 334
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 338,
+            "NameEnd": 341
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 343,
+    "StatementEnd": 409,
+    "RenameTarget": "DICTIONARY",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 361,
+            "NameEnd": 363
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 367,
+            "NameEnd": 370
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 372,
+            "NameEnd": 374
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 378,
+            "NameEnd": 381
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 382,
+      "Expr": {
+        "LiteralPos": 394,
+        "LiteralEnd": 409,
+        "Literal": "default_cluster"
+      }
+    }
+  },
+  {
+    "RenamePos": 431,
+    "StatementEnd": 456,
+    "RenameTarget": "DATABASE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 447,
+            "NameEnd": 449
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 453,
+            "NameEnd": 456
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 458,
+    "StatementEnd": 511,
+    "RenameTarget": "DATABASE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 474,
+            "NameEnd": 476
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 480,
+            "NameEnd": 483
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 484,
+      "Expr": {
+        "LiteralPos": 496,
+        "LiteralEnd": 511,
+        "Literal": "default_cluster"
+      }
+    }
+  },
+  {
+    "RenamePos": 514,
+    "StatementEnd": 550,
+    "RenameTarget": "DATABASE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 530,
+            "NameEnd": 532
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 536,
+            "NameEnd": 539
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 541,
+            "NameEnd": 543
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 547,
+            "NameEnd": 550
+          }
+        }
+      }
+    ],
+    "OnCluster": null
+  },
+  {
+    "RenamePos": 552,
+    "StatementEnd": 616,
+    "RenameTarget": "DATABASE",
+    "TargetPairList": [
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t1",
+            "Unquoted": false,
+            "NamePos": 568,
+            "NameEnd": 570
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t11",
+            "Unquoted": false,
+            "NamePos": 574,
+            "NameEnd": 577
+          }
+        }
+      },
+      {
+        "Old": {
+          "Database": null,
+          "Table": {
+            "Name": "t2",
+            "Unquoted": false,
+            "NamePos": 579,
+            "NameEnd": 581
+          }
+        },
+        "New": {
+          "Database": null,
+          "Table": {
+            "Name": "t22",
+            "Unquoted": false,
+            "NamePos": 585,
+            "NameEnd": 588
+          }
+        }
+      }
+    ],
+    "OnCluster": {
+      "OnPos": 589,
+      "Expr": {
+        "LiteralPos": 601,
+        "LiteralEnd": 616,
+        "Literal": "default_cluster"
+      }
+    }
+  }
+]
\ No newline at end of file
diff --git a/parser/testdata/ddl/output/rename_table.sql.golden.json b/parser/testdata/ddl/output/rename_table.sql.golden.json
deleted file mode 100644
index 27170bd..0000000
--- a/parser/testdata/ddl/output/rename_table.sql.golden.json
+++ /dev/null
@@ -1,164 +0,0 @@
-[
-  {
-    "RenamePos": 0,
-    "StatementEnd": 22,
-    "TablePairList": [
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t1",
-            "Unquoted": false,
-            "NamePos": 13,
-            "NameEnd": 15
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t11",
-            "Unquoted": false,
-            "NamePos": 19,
-            "NameEnd": 22
-          }
-        }
-      }
-    ],
-    "OnCluster": null
-  },
-  {
-    "RenamePos": 24,
-    "StatementEnd": 74,
-    "TablePairList": [
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t1",
-            "Unquoted": false,
-            "NamePos": 37,
-            "NameEnd": 39
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t11",
-            "Unquoted": false,
-            "NamePos": 43,
-            "NameEnd": 46
-          }
-        }
-      }
-    ],
-    "OnCluster": {
-      "OnPos": 47,
-      "Expr": {
-        "LiteralPos": 59,
-        "LiteralEnd": 74,
-        "Literal": "default_cluster"
-      }
-    }
-  },
-  {
-    "RenamePos": 77,
-    "StatementEnd": 110,
-    "TablePairList": [
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t1",
-            "Unquoted": false,
-            "NamePos": 90,
-            "NameEnd": 92
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t11",
-            "Unquoted": false,
-            "NamePos": 96,
-            "NameEnd": 99
-          }
-        }
-      },
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t2",
-            "Unquoted": false,
-            "NamePos": 101,
-            "NameEnd": 103
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t22",
-            "Unquoted": false,
-            "NamePos": 107,
-            "NameEnd": 110
-          }
-        }
-      }
-    ],
-    "OnCluster": null
-  },
-  {
-    "RenamePos": 112,
-    "StatementEnd": 173,
-    "TablePairList": [
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t1",
-            "Unquoted": false,
-            "NamePos": 125,
-            "NameEnd": 127
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t11",
-            "Unquoted": false,
-            "NamePos": 131,
-            "NameEnd": 134
-          }
-        }
-      },
-      {
-        "Old": {
-          "Database": null,
-          "Table": {
-            "Name": "t2",
-            "Unquoted": false,
-            "NamePos": 136,
-            "NameEnd": 138
-          }
-        },
-        "New": {
-          "Database": null,
-          "Table": {
-            "Name": "t22",
-            "Unquoted": false,
-            "NamePos": 142,
-            "NameEnd": 145
-          }
-        }
-      }
-    ],
-    "OnCluster": {
-      "OnPos": 146,
-      "Expr": {
-        "LiteralPos": 158,
-        "LiteralEnd": 173,
-        "Literal": "default_cluster"
-      }
-    }
-  }
-]
\ No newline at end of file
diff --git a/parser/testdata/ddl/rename.sql b/parser/testdata/ddl/rename.sql
new file mode 100644
index 0000000..5242e51
--- /dev/null
+++ b/parser/testdata/ddl/rename.sql
@@ -0,0 +1,15 @@
+-- rename table
+RENAME TABLE t1 TO t11;
+RENAME TABLE t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME TABLE t1 TO t11, t2 TO t22;
+RENAME TABLE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
+-- rename dictionary   
+RENAME DICTIONARY t1 TO t11;
+RENAME DICTIONARY t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME DICTIONARY t1 TO t11, t2 TO t22;
+RENAME DICTIONARY t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
+-- rename database
+RENAME DATABASE t1 TO t11;
+RENAME DATABASE t1 TO t11 ON CLUSTER 'default_cluster';
+RENAME DATABASE t1 TO t11, t2 TO t22;
+RENAME DATABASE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';
diff --git a/parser/testdata/ddl/rename_table.sql b/parser/testdata/ddl/rename_table.sql
deleted file mode 100644
index 6229d65..0000000
--- a/parser/testdata/ddl/rename_table.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-RENAME TABLE t1 TO t11;
-RENAME TABLE t1 TO t11 ON CLUSTER 'default_cluster';
-RENAME TABLE t1 TO t11, t2 TO t22;
-RENAME TABLE t1 TO t11, t2 TO t22 ON CLUSTER 'default_cluster';