Repository: AfterShip/clickhouse-sql-parser
Pull request #26 (2023-11-03 10:22:17)

Fix OnCluster expression should be parsed inside role statement
**From the docs:**

<img width="1187" alt="image" src="https://github.com/AfterShip/clickhouse-sql-parser/assets/107540329/e0984b4f-ab38-4f32-a150-cb3f7542323c">



Patch:
diff --git a/parser/ast.go b/parser/ast.go
index d791b24..750d8e8 100644
--- a/parser/ast.go
+++ b/parser/ast.go
@@ -901,8 +901,9 @@ func (c *CreateFunction) String(level int) string {
 }
 
 type RoleName struct {
-	Name  Expr
-	Scope *StringLiteral
+	Name      Expr
+	Scope     *StringLiteral
+	OnCluster *OnClusterExpr
 }
 
 func (r *RoleName) Pos() Pos {
@@ -913,6 +914,9 @@ func (r *RoleName) End() Pos {
 	if r.Scope != nil {
 		return r.Scope.End()
 	}
+	if r.OnCluster != nil {
+		return r.OnCluster.End()
+	}
 	return r.Name.End()
 }
 
@@ -923,6 +927,10 @@ func (r *RoleName) String(level int) string {
 		builder.WriteString("@")
 		builder.WriteString(r.Scope.String(level))
 	}
+	if r.OnCluster != nil {
+		builder.WriteString(" ON ")
+		builder.WriteString(r.OnCluster.String(level))
+	}
 	return builder.String()
 }
 
@@ -989,7 +997,6 @@ type CreateRole struct {
 	IfNotExists       bool
 	OrReplace         bool
 	RoleNames         []*RoleName
-	OnCluster         *OnClusterExpr
 	AccessStorageType *Ident
 	Settings          []*RoleSetting
 }
@@ -3274,7 +3281,6 @@ type DropUserOrRole struct {
 	StatementEnd Pos
 	Names        []*RoleName
 	IfExists     bool
-	OnCluster    *OnClusterExpr
 	Modifier     string
 	From         *Ident
 }
@@ -3303,10 +3309,6 @@ func (d *DropUserOrRole) String(level int) string {
 		}
 		builder.WriteString(name.String(level))
 	}
-	if d.OnCluster != nil {
-		builder.WriteString(" ")
-		builder.WriteString(d.OnCluster.String(level))
-	}
 	if len(d.Modifier) != 0 {
 		builder.WriteString(" " + d.Modifier)
 	}
diff --git a/parser/parse_system.go b/parser/parse_system.go
index 4cffe52..fd5605c 100644
--- a/parser/parse_system.go
+++ b/parser/parse_system.go
@@ -355,17 +355,27 @@ func (p *Parser) parseRoleName(_ Pos) (*RoleName, error) {
 				return nil, err
 			}
 		}
+		onCluster, err := p.tryParseOnCluster(p.Pos())
+		if err != nil {
+			return nil, err
+		}
 		return &RoleName{
-			Name:  name,
-			Scope: scope,
+			Name:      name,
+			Scope:     scope,
+			OnCluster: onCluster,
 		}, nil
 	case p.matchTokenKind(TokenString):
 		name, err := p.parseString(p.Pos())
 		if err != nil {
 			return nil, err
 		}
+		onCluster, err := p.tryParseOnCluster(p.Pos())
+		if err != nil {
+			return nil, err
+		}
 		return &RoleName{
-			Name: name,
+			Name:      name,
+			OnCluster: onCluster,
 		}, nil
 	default:
 		return nil, fmt.Errorf("expected <ident> or <string>")
@@ -474,11 +484,6 @@ func (p *Parser) parseCreateRole(pos Pos) (*CreateRole, error) {
 	}
 	statementEnd := roleNames[len(roleNames)-1].End()
 
-	onCluster, err := p.tryParseOnCluster(p.Pos())
-	if err != nil {
-		return nil, err
-	}
-
 	var accessStorageType *Ident
 	if p.tryConsumeKeyword(KeywordIn) != nil {
 		accessStorageType, err = p.parseIdent()
@@ -502,7 +507,6 @@ func (p *Parser) parseCreateRole(pos Pos) (*CreateRole, error) {
 		IfNotExists:       ifNotExists,
 		OrReplace:         orReplace,
 		RoleNames:         roleNames,
-		OnCluster:         onCluster,
 		AccessStorageType: accessStorageType,
 		Settings:          settings,
 	}, nil


Test patch:
diff --git a/parser/testdata/ddl/alter_role.sql b/parser/testdata/ddl/alter_role.sql
index b870d82..7dc394a 100644
--- a/parser/testdata/ddl/alter_role.sql
+++ b/parser/testdata/ddl/alter_role.sql
@@ -1,6 +1,7 @@
 -- Tags: no-parallel
 
 ALTER ROLE r1_01293;
+ALTER ROLE r1_01293 ON CLUSTER cluster_1 RENAME TO r2_01293;
 ALTER ROLE r1_01293 RENAME TO r2_01293, r3_01293 RENAME TO r4_01293;
 ALTER ROLE r1_01293 SETTINGS NONE;
 ALTER ROLE r2_01293 SETTINGS PROFILE 'default';
diff --git a/parser/testdata/ddl/create_role.sql b/parser/testdata/ddl/create_role.sql
index bb85036..7a0ac0b 100644
--- a/parser/testdata/ddl/create_role.sql
+++ b/parser/testdata/ddl/create_role.sql
@@ -1,6 +1,10 @@
 -- Tags: no-parallel
 
 CREATE ROLE r1_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1;
+CREATE ROLE r1_01293, r2_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1, r2_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1, r2_01293 ON CLUSTER cluster_2;
 CREATE ROLE r1_01293 SETTINGS NONE;
 CREATE ROLE r2_01293 SETTINGS PROFILE 'default';
 CREATE ROLE r3_01293 SETTINGS max_memory_usage=5000000;
diff --git a/parser/testdata/ddl/format/alter_role.sql b/parser/testdata/ddl/format/alter_role.sql
index c642a8d..761ac82 100644
--- a/parser/testdata/ddl/format/alter_role.sql
+++ b/parser/testdata/ddl/format/alter_role.sql
@@ -2,6 +2,7 @@
 -- Tags: no-parallel
 
 ALTER ROLE r1_01293;
+ALTER ROLE r1_01293 ON CLUSTER cluster_1 RENAME TO r2_01293;
 ALTER ROLE r1_01293 RENAME TO r2_01293, r3_01293 RENAME TO r4_01293;
 ALTER ROLE r1_01293 SETTINGS NONE;
 ALTER ROLE r2_01293 SETTINGS PROFILE 'default';
@@ -23,6 +24,7 @@ ALTER ROLE r2_01293@'%.myhost.com';
 
 -- Format SQL:
 ALTER ROLE r1_01293;
+ALTER ROLE r1_01293 ON ON CLUSTER cluster_1 RENAME TO r2_01293;
 ALTER ROLE r1_01293 RENAME TO r2_01293, r3_01293 RENAME TO r4_01293;
 ALTER ROLE r1_01293 SETTINGS  NONE;
 ALTER ROLE r2_01293 SETTINGS PROFILE 'default';
diff --git a/parser/testdata/ddl/format/create_role.sql b/parser/testdata/ddl/format/create_role.sql
index 37f028a..df1acd1 100644
--- a/parser/testdata/ddl/format/create_role.sql
+++ b/parser/testdata/ddl/format/create_role.sql
@@ -2,6 +2,10 @@
 -- Tags: no-parallel
 
 CREATE ROLE r1_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1;
+CREATE ROLE r1_01293, r2_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1, r2_01293;
+CREATE ROLE r1_01293 ON CLUSTER cluster_1, r2_01293 ON CLUSTER cluster_2;
 CREATE ROLE r1_01293 SETTINGS NONE;
 CREATE ROLE r2_01293 SETTINGS PROFILE 'default';
 CREATE ROLE r3_01293 SETTINGS max_memory_usage=5000000;
@@ -22,6 +26,10 @@ CREATE ROLE r2_01293@'%.myhost.com';
 
 -- Format SQL:
 CREATE ROLE r1_01293;
+CREATE ROLE r1_01293 ON ON CLUSTER cluster_1;
+CREATE ROLE r1_01293, r2_01293;
+CREATE ROLE r1_01293 ON ON CLUSTER cluster_1, r2_01293;
+CREATE ROLE r1_01293 ON ON CLUSTER cluster_1, r2_01293 ON ON CLUSTER cluster_2;
 CREATE ROLE r1_01293 SETTINGS  NONE;
 CREATE ROLE r2_01293 SETTINGS PROFILE 'default';
 CREATE ROLE r3_01293 SETTINGS max_memory_usage 5000000;
diff --git a/parser/testdata/ddl/output/alter_role.sql.golden.json b/parser/testdata/ddl/output/alter_role.sql.golden.json
index f70b7b2..980d86c 100644
--- a/parser/testdata/ddl/output/alter_role.sql.golden.json
+++ b/parser/testdata/ddl/output/alter_role.sql.golden.json
@@ -12,7 +12,8 @@
             "NamePos": 33,
             "NameEnd": 41
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
         "StatementEnd": 41
@@ -22,7 +23,7 @@
   },
   {
     "AlterPos": 43,
-    "StatementEnd": 110,
+    "StatementEnd": 102,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -33,40 +34,77 @@
             "NamePos": 54,
             "NameEnd": 62
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": {
+            "OnPos": 63,
+            "Expr": {
+              "Name": "cluster_1",
+              "Unquoted": false,
+              "NamePos": 74,
+              "NameEnd": 83
+            }
+          }
         },
         "NewName": {
           "Name": "r2_01293",
           "Unquoted": false,
-          "NamePos": 73,
-          "NameEnd": 81
+          "NamePos": 94,
+          "NameEnd": 102
         },
-        "StatementEnd": 81
+        "StatementEnd": 102
+      }
+    ],
+    "Settings": null
+  },
+  {
+    "AlterPos": 104,
+    "StatementEnd": 171,
+    "IfExists": false,
+    "RoleRenamePairs": [
+      {
+        "RoleName": {
+          "Name": {
+            "Name": "r1_01293",
+            "Unquoted": false,
+            "NamePos": 115,
+            "NameEnd": 123
+          },
+          "Scope": null,
+          "OnCluster": null
+        },
+        "NewName": {
+          "Name": "r2_01293",
+          "Unquoted": false,
+          "NamePos": 134,
+          "NameEnd": 142
+        },
+        "StatementEnd": 142
       },
       {
         "RoleName": {
           "Name": {
             "Name": "r3_01293",
             "Unquoted": false,
-            "NamePos": 83,
-            "NameEnd": 91
+            "NamePos": 144,
+            "NameEnd": 152
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": {
           "Name": "r4_01293",
           "Unquoted": false,
-          "NamePos": 102,
-          "NameEnd": 110
+          "NamePos": 163,
+          "NameEnd": 171
         },
-        "StatementEnd": 110
+        "StatementEnd": 171
       }
     ],
     "Settings": null
   },
   {
-    "AlterPos": 112,
-    "StatementEnd": 145,
+    "AlterPos": 173,
+    "StatementEnd": 206,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -74,13 +112,14 @@
           "Name": {
             "Name": "r1_01293",
             "Unquoted": false,
-            "NamePos": 123,
-            "NameEnd": 131
+            "NamePos": 184,
+            "NameEnd": 192
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 131
+        "StatementEnd": 192
       }
     ],
     "Settings": [
@@ -89,15 +128,15 @@
         "Modifier": {
           "Name": "NONE",
           "Unquoted": false,
-          "NamePos": 141,
-          "NameEnd": 145
+          "NamePos": 202,
+          "NameEnd": 206
         }
       }
     ]
   },
   {
-    "AlterPos": 147,
-    "StatementEnd": 192,
+    "AlterPos": 208,
+    "StatementEnd": 253,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -105,13 +144,14 @@
           "Name": {
             "Name": "r2_01293",
             "Unquoted": false,
-            "NamePos": 158,
-            "NameEnd": 166
+            "NamePos": 219,
+            "NameEnd": 227
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 166
+        "StatementEnd": 227
       }
     ],
     "Settings": [
@@ -121,12 +161,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 176,
-              "NameEnd": 183
+              "NamePos": 237,
+              "NameEnd": 244
             },
             "Value": {
-              "LiteralPos": 185,
-              "LiteralEnd": 192,
+              "LiteralPos": 246,
+              "LiteralEnd": 253,
               "Literal": "default"
             }
           }
@@ -136,8 +176,8 @@
     ]
   },
   {
-    "AlterPos": 195,
-    "StatementEnd": 248,
+    "AlterPos": 256,
+    "StatementEnd": 309,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -145,13 +185,14 @@
           "Name": {
             "Name": "r3_01293",
             "Unquoted": false,
-            "NamePos": 206,
-            "NameEnd": 214
+            "NamePos": 267,
+            "NameEnd": 275
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 214
+        "StatementEnd": 275
       }
     ],
     "Settings": [
@@ -161,12 +202,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 224,
-              "NameEnd": 240
+              "NamePos": 285,
+              "NameEnd": 301
             },
             "Value": {
-              "NumPos": 241,
-              "NumEnd": 248,
+              "NumPos": 302,
+              "NumEnd": 309,
               "Literal": "5000000",
               "Base": 10
             }
@@ -177,8 +218,8 @@
     ]
   },
   {
-    "AlterPos": 250,
-    "StatementEnd": 307,
+    "AlterPos": 311,
+    "StatementEnd": 368,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -186,13 +227,14 @@
           "Name": {
             "Name": "r4_01293",
             "Unquoted": false,
-            "NamePos": 261,
-            "NameEnd": 269
+            "NamePos": 322,
+            "NameEnd": 330
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 269
+        "StatementEnd": 330
       }
     ],
     "Settings": [
@@ -202,8 +244,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 279,
-              "NameEnd": 295
+              "NamePos": 340,
+              "NameEnd": 356
             },
             "Value": null
           },
@@ -211,12 +253,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 296,
-              "NameEnd": 299
+              "NamePos": 357,
+              "NameEnd": 360
             },
             "Value": {
-              "NumPos": 300,
-              "NumEnd": 307,
+              "NumPos": 361,
+              "NumEnd": 368,
               "Literal": "5000000",
               "Base": 10
             }
@@ -227,8 +269,8 @@
     ]
   },
   {
-    "AlterPos": 309,
-    "StatementEnd": 366,
+    "AlterPos": 370,
+    "StatementEnd": 427,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -236,13 +278,14 @@
           "Name": {
             "Name": "r5_01293",
             "Unquoted": false,
-            "NamePos": 320,
-            "NameEnd": 328
+            "NamePos": 381,
+            "NameEnd": 389
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 328
+        "StatementEnd": 389
       }
     ],
     "Settings": [
@@ -252,8 +295,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 338,
-              "NameEnd": 354
+              "NamePos": 399,
+              "NameEnd": 415
             },
             "Value": null
           },
@@ -261,12 +304,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 355,
-              "NameEnd": 358
+              "NamePos": 416,
+              "NameEnd": 419
             },
             "Value": {
-              "NumPos": 359,
-              "NumEnd": 366,
+              "NumPos": 420,
+              "NumEnd": 427,
               "Literal": "5000000",
               "Base": 10
             }
@@ -277,8 +320,8 @@
     ]
   },
   {
-    "AlterPos": 368,
-    "StatementEnd": 419,
+    "AlterPos": 429,
+    "StatementEnd": 480,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -286,13 +329,14 @@
           "Name": {
             "Name": "r6_01293",
             "Unquoted": false,
-            "NamePos": 379,
-            "NameEnd": 387
+            "NamePos": 440,
+            "NameEnd": 448
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 387
+        "StatementEnd": 448
       }
     ],
     "Settings": [
@@ -302,8 +346,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 397,
-              "NameEnd": 413
+              "NamePos": 458,
+              "NameEnd": 474
             },
             "Value": null
           }
@@ -311,15 +355,15 @@
         "Modifier": {
           "Name": "CONST",
           "Unquoted": false,
-          "NamePos": 414,
-          "NameEnd": 419
+          "NamePos": 475,
+          "NameEnd": 480
         }
       }
     ]
   },
   {
-    "AlterPos": 421,
-    "StatementEnd": 475,
+    "AlterPos": 482,
+    "StatementEnd": 536,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -327,13 +371,14 @@
           "Name": {
             "Name": "r7_01293",
             "Unquoted": false,
-            "NamePos": 432,
-            "NameEnd": 440
+            "NamePos": 493,
+            "NameEnd": 501
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 440
+        "StatementEnd": 501
       }
     ],
     "Settings": [
@@ -343,8 +388,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 450,
-              "NameEnd": 466
+              "NamePos": 511,
+              "NameEnd": 527
             },
             "Value": null
           }
@@ -352,15 +397,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 467,
-          "NameEnd": 475
+          "NamePos": 528,
+          "NameEnd": 536
         }
       }
     ]
   },
   {
-    "AlterPos": 477,
-    "StatementEnd": 560,
+    "AlterPos": 538,
+    "StatementEnd": 621,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -368,13 +413,14 @@
           "Name": {
             "Name": "r8_01293",
             "Unquoted": false,
-            "NamePos": 488,
-            "NameEnd": 496
+            "NamePos": 549,
+            "NameEnd": 557
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 496
+        "StatementEnd": 557
       }
     ],
     "Settings": [
@@ -384,12 +430,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 506,
-              "NameEnd": 522
+              "NamePos": 567,
+              "NameEnd": 583
             },
             "Value": {
-              "NumPos": 523,
-              "NumEnd": 530,
+              "NumPos": 584,
+              "NumEnd": 591,
               "Literal": "5000000",
               "Base": 10
             }
@@ -398,12 +444,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 531,
-              "NameEnd": 534
+              "NamePos": 592,
+              "NameEnd": 595
             },
             "Value": {
-              "NumPos": 535,
-              "NumEnd": 542,
+              "NumPos": 596,
+              "NumEnd": 603,
               "Literal": "4000000",
               "Base": 10
             }
@@ -412,12 +458,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 543,
-              "NameEnd": 546
+              "NamePos": 604,
+              "NameEnd": 607
             },
             "Value": {
-              "NumPos": 547,
-              "NumEnd": 554,
+              "NumPos": 608,
+              "NumEnd": 615,
               "Literal": "6000000",
               "Base": 10
             }
@@ -426,15 +472,15 @@
         "Modifier": {
           "Name": "CONST",
           "Unquoted": false,
-          "NamePos": 555,
-          "NameEnd": 560
+          "NamePos": 616,
+          "NameEnd": 621
         }
       }
     ]
   },
   {
-    "AlterPos": 562,
-    "StatementEnd": 643,
+    "AlterPos": 623,
+    "StatementEnd": 704,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -442,13 +488,14 @@
           "Name": {
             "Name": "r9_01293",
             "Unquoted": false,
-            "NamePos": 573,
-            "NameEnd": 581
+            "NamePos": 634,
+            "NameEnd": 642
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 581
+        "StatementEnd": 642
       }
     ],
     "Settings": [
@@ -458,12 +505,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 591,
-              "NameEnd": 598
+              "NamePos": 652,
+              "NameEnd": 659
             },
             "Value": {
-              "LiteralPos": 600,
-              "LiteralEnd": 607,
+              "LiteralPos": 661,
+              "LiteralEnd": 668,
               "Literal": "default"
             }
           }
@@ -476,12 +523,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 610,
-              "NameEnd": 626
+              "NamePos": 671,
+              "NameEnd": 687
             },
             "Value": {
-              "NumPos": 627,
-              "NumEnd": 634,
+              "NumPos": 688,
+              "NumEnd": 695,
               "Literal": "5000000",
               "Base": 10
             }
@@ -490,15 +537,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 635,
-          "NameEnd": 643
+          "NamePos": 696,
+          "NameEnd": 704
         }
       }
     ]
   },
   {
-    "AlterPos": 645,
-    "StatementEnd": 674,
+    "AlterPos": 706,
+    "StatementEnd": 735,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -506,33 +553,35 @@
           "Name": {
             "Name": "r1_01293",
             "Unquoted": false,
-            "NamePos": 656,
-            "NameEnd": 664
+            "NamePos": 717,
+            "NameEnd": 725
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 664
+        "StatementEnd": 725
       },
       {
         "RoleName": {
           "Name": {
             "Name": "r2_01293",
             "Unquoted": false,
-            "NamePos": 666,
-            "NameEnd": 674
+            "NamePos": 727,
+            "NameEnd": 735
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 674
+        "StatementEnd": 735
       }
     ],
     "Settings": null
   },
   {
-    "AlterPos": 676,
-    "StatementEnd": 715,
+    "AlterPos": 737,
+    "StatementEnd": 776,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -540,13 +589,14 @@
           "Name": {
             "Name": "r1_01293",
             "Unquoted": false,
-            "NamePos": 687,
-            "NameEnd": 695
+            "NamePos": 748,
+            "NameEnd": 756
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 695
+        "StatementEnd": 756
       }
     ],
     "Settings": [
@@ -556,12 +606,12 @@
             "Name": {
               "Name": "readonly",
               "Unquoted": false,
-              "NamePos": 705,
-              "NameEnd": 713
+              "NamePos": 766,
+              "NameEnd": 774
             },
             "Value": {
-              "NumPos": 714,
-              "NumEnd": 715,
+              "NumPos": 775,
+              "NumEnd": 776,
               "Literal": "1",
               "Base": 10
             }
@@ -572,8 +622,8 @@
     ]
   },
   {
-    "AlterPos": 717,
-    "StatementEnd": 762,
+    "AlterPos": 778,
+    "StatementEnd": 823,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -581,13 +631,14 @@
           "Name": {
             "Name": "r2_01293",
             "Unquoted": false,
-            "NamePos": 728,
-            "NameEnd": 736
+            "NamePos": 789,
+            "NameEnd": 797
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 736
+        "StatementEnd": 797
       }
     ],
     "Settings": [
@@ -597,12 +648,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 746,
-              "NameEnd": 753
+              "NamePos": 807,
+              "NameEnd": 814
             },
             "Value": {
-              "LiteralPos": 755,
-              "LiteralEnd": 762,
+              "LiteralPos": 816,
+              "LiteralEnd": 823,
               "Literal": "default"
             }
           }
@@ -612,8 +663,8 @@
     ]
   },
   {
-    "AlterPos": 765,
-    "StatementEnd": 851,
+    "AlterPos": 826,
+    "StatementEnd": 912,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -621,13 +672,14 @@
           "Name": {
             "Name": "r3_01293",
             "Unquoted": false,
-            "NamePos": 776,
-            "NameEnd": 784
+            "NamePos": 837,
+            "NameEnd": 845
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 784
+        "StatementEnd": 845
       }
     ],
     "Settings": [
@@ -637,12 +689,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 794,
-              "NameEnd": 810
+              "NamePos": 855,
+              "NameEnd": 871
             },
             "Value": {
-              "NumPos": 811,
-              "NumEnd": 818,
+              "NumPos": 872,
+              "NumEnd": 879,
               "Literal": "5000000",
               "Base": 10
             }
@@ -651,12 +703,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 819,
-              "NameEnd": 822
+              "NamePos": 880,
+              "NameEnd": 883
             },
             "Value": {
-              "NumPos": 823,
-              "NumEnd": 830,
+              "NumPos": 884,
+              "NumEnd": 891,
               "Literal": "4000000",
               "Base": 10
             }
@@ -665,12 +717,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 831,
-              "NameEnd": 834
+              "NamePos": 892,
+              "NameEnd": 895
             },
             "Value": {
-              "NumPos": 835,
-              "NumEnd": 842,
+              "NumPos": 896,
+              "NumEnd": 903,
               "Literal": "6000000",
               "Base": 10
             }
@@ -679,15 +731,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 843,
-          "NameEnd": 851
+          "NamePos": 904,
+          "NameEnd": 912
         }
       }
     ]
   },
   {
-    "AlterPos": 853,
-    "StatementEnd": 937,
+    "AlterPos": 914,
+    "StatementEnd": 998,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -695,13 +747,14 @@
           "Name": {
             "Name": "r4_01293",
             "Unquoted": false,
-            "NamePos": 864,
-            "NameEnd": 872
+            "NamePos": 925,
+            "NameEnd": 933
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 872
+        "StatementEnd": 933
       }
     ],
     "Settings": [
@@ -711,12 +764,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 882,
-              "NameEnd": 889
+              "NamePos": 943,
+              "NameEnd": 950
             },
             "Value": {
-              "LiteralPos": 891,
-              "LiteralEnd": 898,
+              "LiteralPos": 952,
+              "LiteralEnd": 959,
               "Literal": "default"
             }
           }
@@ -729,12 +782,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 901,
-              "NameEnd": 917
+              "NamePos": 962,
+              "NameEnd": 978
             },
             "Value": {
-              "NumPos": 918,
-              "NumEnd": 925,
+              "NumPos": 979,
+              "NumEnd": 986,
               "Literal": "5000000",
               "Base": 10
             }
@@ -748,12 +801,12 @@
             "Name": {
               "Name": "readonly",
               "Unquoted": false,
-              "NamePos": 927,
-              "NameEnd": 935
+              "NamePos": 988,
+              "NameEnd": 996
             },
             "Value": {
-              "NumPos": 936,
-              "NumEnd": 937,
+              "NumPos": 997,
+              "NumEnd": 998,
               "Literal": "1",
               "Base": 10
             }
@@ -764,8 +817,8 @@
     ]
   },
   {
-    "AlterPos": 939,
-    "StatementEnd": 972,
+    "AlterPos": 1000,
+    "StatementEnd": 1033,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -773,13 +826,14 @@
           "Name": {
             "Name": "r5_01293",
             "Unquoted": false,
-            "NamePos": 950,
-            "NameEnd": 958
+            "NamePos": 1011,
+            "NameEnd": 1019
           },
-          "Scope": null
+          "Scope": null,
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 958
+        "StatementEnd": 1019
       }
     ],
     "Settings": [
@@ -788,15 +842,15 @@
         "Modifier": {
           "Name": "NONE",
           "Unquoted": false,
-          "NamePos": 968,
-          "NameEnd": 972
+          "NamePos": 1029,
+          "NameEnd": 1033
         }
       }
     ]
   },
   {
-    "AlterPos": 974,
-    "StatementEnd": 996,
+    "AlterPos": 1035,
+    "StatementEnd": 1057,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -804,24 +858,25 @@
           "Name": {
             "Name": "r1_01293",
             "Unquoted": false,
-            "NamePos": 985,
-            "NameEnd": 993
+            "NamePos": 1046,
+            "NameEnd": 1054
           },
           "Scope": {
-            "LiteralPos": 995,
-            "LiteralEnd": 996,
+            "LiteralPos": 1056,
+            "LiteralEnd": 1057,
             "Literal": "%"
-          }
+          },
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 996
+        "StatementEnd": 1057
       }
     ],
     "Settings": null
   },
   {
-    "AlterPos": 999,
-    "StatementEnd": 1032,
+    "AlterPos": 1060,
+    "StatementEnd": 1093,
     "IfExists": false,
     "RoleRenamePairs": [
       {
@@ -829,17 +884,18 @@
           "Name": {
             "Name": "r2_01293",
             "Unquoted": false,
-            "NamePos": 1010,
-            "NameEnd": 1018
+            "NamePos": 1071,
+            "NameEnd": 1079
           },
           "Scope": {
-            "LiteralPos": 1020,
-            "LiteralEnd": 1032,
+            "LiteralPos": 1081,
+            "LiteralEnd": 1093,
             "Literal": "%.myhost.com"
-          }
+          },
+          "OnCluster": null
         },
         "NewName": null,
-        "StatementEnd": 1032
+        "StatementEnd": 1093
       }
     ],
     "Settings": null
diff --git a/parser/testdata/ddl/output/create_role.sql.golden.json b/parser/testdata/ddl/output/create_role.sql.golden.json
index 86f6b85..f81f640 100644
--- a/parser/testdata/ddl/output/create_role.sql.golden.json
+++ b/parser/testdata/ddl/output/create_role.sql.golden.json
@@ -12,16 +12,16 @@
           "NamePos": 34,
           "NameEnd": 42
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": null
   },
   {
     "CreatePos": 44,
-    "StatementEnd": 78,
+    "StatementEnd": 85,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -32,10 +32,152 @@
           "NamePos": 56,
           "NameEnd": 64
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": {
+          "OnPos": 65,
+          "Expr": {
+            "Name": "cluster_1",
+            "Unquoted": false,
+            "NamePos": 76,
+            "NameEnd": 85
+          }
+        }
+      }
+    ],
+    "AccessStorageType": null,
+    "Settings": null
+  },
+  {
+    "CreatePos": 87,
+    "StatementEnd": 117,
+    "IfNotExists": false,
+    "OrReplace": false,
+    "RoleNames": [
+      {
+        "Name": {
+          "Name": "r1_01293",
+          "Unquoted": false,
+          "NamePos": 99,
+          "NameEnd": 107
+        },
+        "Scope": null,
+        "OnCluster": null
+      },
+      {
+        "Name": {
+          "Name": "r2_01293",
+          "Unquoted": false,
+          "NamePos": 109,
+          "NameEnd": 117
+        },
+        "Scope": null,
+        "OnCluster": null
+      }
+    ],
+    "AccessStorageType": null,
+    "Settings": null
+  },
+  {
+    "CreatePos": 119,
+    "StatementEnd": 170,
+    "IfNotExists": false,
+    "OrReplace": false,
+    "RoleNames": [
+      {
+        "Name": {
+          "Name": "r1_01293",
+          "Unquoted": false,
+          "NamePos": 131,
+          "NameEnd": 139
+        },
+        "Scope": null,
+        "OnCluster": {
+          "OnPos": 140,
+          "Expr": {
+            "Name": "cluster_1",
+            "Unquoted": false,
+            "NamePos": 151,
+            "NameEnd": 160
+          }
+        }
+      },
+      {
+        "Name": {
+          "Name": "r2_01293",
+          "Unquoted": false,
+          "NamePos": 162,
+          "NameEnd": 170
+        },
+        "Scope": null,
+        "OnCluster": null
+      }
+    ],
+    "AccessStorageType": null,
+    "Settings": null
+  },
+  {
+    "CreatePos": 172,
+    "StatementEnd": 244,
+    "IfNotExists": false,
+    "OrReplace": false,
+    "RoleNames": [
+      {
+        "Name": {
+          "Name": "r1_01293",
+          "Unquoted": false,
+          "NamePos": 184,
+          "NameEnd": 192
+        },
+        "Scope": null,
+        "OnCluster": {
+          "OnPos": 193,
+          "Expr": {
+            "Name": "cluster_1",
+            "Unquoted": false,
+            "NamePos": 204,
+            "NameEnd": 213
+          }
+        }
+      },
+      {
+        "Name": {
+          "Name": "r2_01293",
+          "Unquoted": false,
+          "NamePos": 215,
+          "NameEnd": 223
+        },
+        "Scope": null,
+        "OnCluster": {
+          "OnPos": 224,
+          "Expr": {
+            "Name": "cluster_2",
+            "Unquoted": false,
+            "NamePos": 235,
+            "NameEnd": 244
+          }
+        }
+      }
+    ],
+    "AccessStorageType": null,
+    "Settings": null
+  },
+  {
+    "CreatePos": 246,
+    "StatementEnd": 280,
+    "IfNotExists": false,
+    "OrReplace": false,
+    "RoleNames": [
+      {
+        "Name": {
+          "Name": "r1_01293",
+          "Unquoted": false,
+          "NamePos": 258,
+          "NameEnd": 266
+        },
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -43,15 +185,15 @@
         "Modifier": {
           "Name": "NONE",
           "Unquoted": false,
-          "NamePos": 74,
-          "NameEnd": 78
+          "NamePos": 276,
+          "NameEnd": 280
         }
       }
     ]
   },
   {
-    "CreatePos": 80,
-    "StatementEnd": 126,
+    "CreatePos": 282,
+    "StatementEnd": 328,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -59,13 +201,13 @@
         "Name": {
           "Name": "r2_01293",
           "Unquoted": false,
-          "NamePos": 92,
-          "NameEnd": 100
+          "NamePos": 294,
+          "NameEnd": 302
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -74,12 +216,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 110,
-              "NameEnd": 117
+              "NamePos": 312,
+              "NameEnd": 319
             },
             "Value": {
-              "LiteralPos": 119,
-              "LiteralEnd": 126,
+              "LiteralPos": 321,
+              "LiteralEnd": 328,
               "Literal": "default"
             }
           }
@@ -89,8 +231,8 @@
     ]
   },
   {
-    "CreatePos": 129,
-    "StatementEnd": 183,
+    "CreatePos": 331,
+    "StatementEnd": 385,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -98,13 +240,13 @@
         "Name": {
           "Name": "r3_01293",
           "Unquoted": false,
-          "NamePos": 141,
-          "NameEnd": 149
+          "NamePos": 343,
+          "NameEnd": 351
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -113,12 +255,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 159,
-              "NameEnd": 175
+              "NamePos": 361,
+              "NameEnd": 377
             },
             "Value": {
-              "NumPos": 176,
-              "NumEnd": 183,
+              "NumPos": 378,
+              "NumEnd": 385,
               "Literal": "5000000",
               "Base": 10
             }
@@ -129,8 +271,8 @@
     ]
   },
   {
-    "CreatePos": 185,
-    "StatementEnd": 243,
+    "CreatePos": 387,
+    "StatementEnd": 445,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -138,13 +280,13 @@
         "Name": {
           "Name": "r4_01293",
           "Unquoted": false,
-          "NamePos": 197,
-          "NameEnd": 205
+          "NamePos": 399,
+          "NameEnd": 407
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -153,8 +295,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 215,
-              "NameEnd": 231
+              "NamePos": 417,
+              "NameEnd": 433
             },
             "Value": null
           },
@@ -162,12 +304,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 232,
-              "NameEnd": 235
+              "NamePos": 434,
+              "NameEnd": 437
             },
             "Value": {
-              "NumPos": 236,
-              "NumEnd": 243,
+              "NumPos": 438,
+              "NumEnd": 445,
               "Literal": "5000000",
               "Base": 10
             }
@@ -178,8 +320,8 @@
     ]
   },
   {
-    "CreatePos": 245,
-    "StatementEnd": 303,
+    "CreatePos": 447,
+    "StatementEnd": 505,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -187,13 +329,13 @@
         "Name": {
           "Name": "r5_01293",
           "Unquoted": false,
-          "NamePos": 257,
-          "NameEnd": 265
+          "NamePos": 459,
+          "NameEnd": 467
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -202,8 +344,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 275,
-              "NameEnd": 291
+              "NamePos": 477,
+              "NameEnd": 493
             },
             "Value": null
           },
@@ -211,12 +353,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 292,
-              "NameEnd": 295
+              "NamePos": 494,
+              "NameEnd": 497
             },
             "Value": {
-              "NumPos": 296,
-              "NumEnd": 303,
+              "NumPos": 498,
+              "NumEnd": 505,
               "Literal": "5000000",
               "Base": 10
             }
@@ -227,8 +369,8 @@
     ]
   },
   {
-    "CreatePos": 305,
-    "StatementEnd": 357,
+    "CreatePos": 507,
+    "StatementEnd": 559,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -236,13 +378,13 @@
         "Name": {
           "Name": "r6_01293",
           "Unquoted": false,
-          "NamePos": 317,
-          "NameEnd": 325
+          "NamePos": 519,
+          "NameEnd": 527
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -251,8 +393,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 335,
-              "NameEnd": 351
+              "NamePos": 537,
+              "NameEnd": 553
             },
             "Value": null
           }
@@ -260,15 +402,15 @@
         "Modifier": {
           "Name": "CONST",
           "Unquoted": false,
-          "NamePos": 352,
-          "NameEnd": 357
+          "NamePos": 554,
+          "NameEnd": 559
         }
       }
     ]
   },
   {
-    "CreatePos": 359,
-    "StatementEnd": 414,
+    "CreatePos": 561,
+    "StatementEnd": 616,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -276,13 +418,13 @@
         "Name": {
           "Name": "r7_01293",
           "Unquoted": false,
-          "NamePos": 371,
-          "NameEnd": 379
+          "NamePos": 573,
+          "NameEnd": 581
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -291,8 +433,8 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 389,
-              "NameEnd": 405
+              "NamePos": 591,
+              "NameEnd": 607
             },
             "Value": null
           }
@@ -300,15 +442,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 406,
-          "NameEnd": 414
+          "NamePos": 608,
+          "NameEnd": 616
         }
       }
     ]
   },
   {
-    "CreatePos": 416,
-    "StatementEnd": 500,
+    "CreatePos": 618,
+    "StatementEnd": 702,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -316,13 +458,13 @@
         "Name": {
           "Name": "r8_01293",
           "Unquoted": false,
-          "NamePos": 428,
-          "NameEnd": 436
+          "NamePos": 630,
+          "NameEnd": 638
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -331,12 +473,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 446,
-              "NameEnd": 462
+              "NamePos": 648,
+              "NameEnd": 664
             },
             "Value": {
-              "NumPos": 463,
-              "NumEnd": 470,
+              "NumPos": 665,
+              "NumEnd": 672,
               "Literal": "5000000",
               "Base": 10
             }
@@ -345,12 +487,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 471,
-              "NameEnd": 474
+              "NamePos": 673,
+              "NameEnd": 676
             },
             "Value": {
-              "NumPos": 475,
-              "NumEnd": 482,
+              "NumPos": 677,
+              "NumEnd": 684,
               "Literal": "4000000",
               "Base": 10
             }
@@ -359,12 +501,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 483,
-              "NameEnd": 486
+              "NamePos": 685,
+              "NameEnd": 688
             },
             "Value": {
-              "NumPos": 487,
-              "NumEnd": 494,
+              "NumPos": 689,
+              "NumEnd": 696,
               "Literal": "6000000",
               "Base": 10
             }
@@ -373,15 +515,15 @@
         "Modifier": {
           "Name": "CONST",
           "Unquoted": false,
-          "NamePos": 495,
-          "NameEnd": 500
+          "NamePos": 697,
+          "NameEnd": 702
         }
       }
     ]
   },
   {
-    "CreatePos": 502,
-    "StatementEnd": 584,
+    "CreatePos": 704,
+    "StatementEnd": 786,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -389,13 +531,13 @@
         "Name": {
           "Name": "r9_01293",
           "Unquoted": false,
-          "NamePos": 514,
-          "NameEnd": 522
+          "NamePos": 716,
+          "NameEnd": 724
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -404,12 +546,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 532,
-              "NameEnd": 539
+              "NamePos": 734,
+              "NameEnd": 741
             },
             "Value": {
-              "LiteralPos": 541,
-              "LiteralEnd": 548,
+              "LiteralPos": 743,
+              "LiteralEnd": 750,
               "Literal": "default"
             }
           }
@@ -422,12 +564,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 551,
-              "NameEnd": 567
+              "NamePos": 753,
+              "NameEnd": 769
             },
             "Value": {
-              "NumPos": 568,
-              "NumEnd": 575,
+              "NumPos": 770,
+              "NumEnd": 777,
               "Literal": "5000000",
               "Base": 10
             }
@@ -436,15 +578,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 576,
-          "NameEnd": 584
+          "NamePos": 778,
+          "NameEnd": 786
         }
       }
     ]
   },
   {
-    "CreatePos": 586,
-    "StatementEnd": 616,
+    "CreatePos": 788,
+    "StatementEnd": 818,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -452,28 +594,29 @@
         "Name": {
           "Name": "r1_01293",
           "Unquoted": false,
-          "NamePos": 598,
-          "NameEnd": 606
+          "NamePos": 800,
+          "NameEnd": 808
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
           "Name": "r2_01293",
           "Unquoted": false,
-          "NamePos": 608,
-          "NameEnd": 616
+          "NamePos": 810,
+          "NameEnd": 818
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": null
   },
   {
-    "CreatePos": 618,
-    "StatementEnd": 658,
+    "CreatePos": 820,
+    "StatementEnd": 860,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -481,13 +624,13 @@
         "Name": {
           "Name": "r1_01293",
           "Unquoted": false,
-          "NamePos": 630,
-          "NameEnd": 638
+          "NamePos": 832,
+          "NameEnd": 840
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -496,12 +639,12 @@
             "Name": {
               "Name": "readonly",
               "Unquoted": false,
-              "NamePos": 648,
-              "NameEnd": 656
+              "NamePos": 850,
+              "NameEnd": 858
             },
             "Value": {
-              "NumPos": 657,
-              "NumEnd": 658,
+              "NumPos": 859,
+              "NumEnd": 860,
               "Literal": "1",
               "Base": 10
             }
@@ -512,8 +655,8 @@
     ]
   },
   {
-    "CreatePos": 660,
-    "StatementEnd": 706,
+    "CreatePos": 862,
+    "StatementEnd": 908,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -521,13 +664,13 @@
         "Name": {
           "Name": "r2_01293",
           "Unquoted": false,
-          "NamePos": 672,
-          "NameEnd": 680
+          "NamePos": 874,
+          "NameEnd": 882
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -536,12 +679,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 690,
-              "NameEnd": 697
+              "NamePos": 892,
+              "NameEnd": 899
             },
             "Value": {
-              "LiteralPos": 699,
-              "LiteralEnd": 706,
+              "LiteralPos": 901,
+              "LiteralEnd": 908,
               "Literal": "default"
             }
           }
@@ -551,8 +694,8 @@
     ]
   },
   {
-    "CreatePos": 709,
-    "StatementEnd": 796,
+    "CreatePos": 911,
+    "StatementEnd": 998,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -560,13 +703,13 @@
         "Name": {
           "Name": "r3_01293",
           "Unquoted": false,
-          "NamePos": 721,
-          "NameEnd": 729
+          "NamePos": 923,
+          "NameEnd": 931
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -575,12 +718,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 739,
-              "NameEnd": 755
+              "NamePos": 941,
+              "NameEnd": 957
             },
             "Value": {
-              "NumPos": 756,
-              "NumEnd": 763,
+              "NumPos": 958,
+              "NumEnd": 965,
               "Literal": "5000000",
               "Base": 10
             }
@@ -589,12 +732,12 @@
             "Name": {
               "Name": "MIN",
               "Unquoted": false,
-              "NamePos": 764,
-              "NameEnd": 767
+              "NamePos": 966,
+              "NameEnd": 969
             },
             "Value": {
-              "NumPos": 768,
-              "NumEnd": 775,
+              "NumPos": 970,
+              "NumEnd": 977,
               "Literal": "4000000",
               "Base": 10
             }
@@ -603,12 +746,12 @@
             "Name": {
               "Name": "MAX",
               "Unquoted": false,
-              "NamePos": 776,
-              "NameEnd": 779
+              "NamePos": 978,
+              "NameEnd": 981
             },
             "Value": {
-              "NumPos": 780,
-              "NumEnd": 787,
+              "NumPos": 982,
+              "NumEnd": 989,
               "Literal": "6000000",
               "Base": 10
             }
@@ -617,15 +760,15 @@
         "Modifier": {
           "Name": "WRITABLE",
           "Unquoted": false,
-          "NamePos": 788,
-          "NameEnd": 796
+          "NamePos": 990,
+          "NameEnd": 998
         }
       }
     ]
   },
   {
-    "CreatePos": 798,
-    "StatementEnd": 883,
+    "CreatePos": 1000,
+    "StatementEnd": 1085,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -633,13 +776,13 @@
         "Name": {
           "Name": "r4_01293",
           "Unquoted": false,
-          "NamePos": 810,
-          "NameEnd": 818
+          "NamePos": 1012,
+          "NameEnd": 1020
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -648,12 +791,12 @@
             "Name": {
               "Name": "PROFILE",
               "Unquoted": false,
-              "NamePos": 828,
-              "NameEnd": 835
+              "NamePos": 1030,
+              "NameEnd": 1037
             },
             "Value": {
-              "LiteralPos": 837,
-              "LiteralEnd": 844,
+              "LiteralPos": 1039,
+              "LiteralEnd": 1046,
               "Literal": "default"
             }
           }
@@ -666,12 +809,12 @@
             "Name": {
               "Name": "max_memory_usage",
               "Unquoted": false,
-              "NamePos": 847,
-              "NameEnd": 863
+              "NamePos": 1049,
+              "NameEnd": 1065
             },
             "Value": {
-              "NumPos": 864,
-              "NumEnd": 871,
+              "NumPos": 1066,
+              "NumEnd": 1073,
               "Literal": "5000000",
               "Base": 10
             }
@@ -685,12 +828,12 @@
             "Name": {
               "Name": "readonly",
               "Unquoted": false,
-              "NamePos": 873,
-              "NameEnd": 881
+              "NamePos": 1075,
+              "NameEnd": 1083
             },
             "Value": {
-              "NumPos": 882,
-              "NumEnd": 883,
+              "NumPos": 1084,
+              "NumEnd": 1085,
               "Literal": "1",
               "Base": 10
             }
@@ -701,8 +844,8 @@
     ]
   },
   {
-    "CreatePos": 885,
-    "StatementEnd": 919,
+    "CreatePos": 1087,
+    "StatementEnd": 1121,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -710,13 +853,13 @@
         "Name": {
           "Name": "r5_01293",
           "Unquoted": false,
-          "NamePos": 897,
-          "NameEnd": 905
+          "NamePos": 1099,
+          "NameEnd": 1107
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": [
       {
@@ -724,15 +867,15 @@
         "Modifier": {
           "Name": "NONE",
           "Unquoted": false,
-          "NamePos": 915,
-          "NameEnd": 919
+          "NamePos": 1117,
+          "NameEnd": 1121
         }
       }
     ]
   },
   {
-    "CreatePos": 921,
-    "StatementEnd": 944,
+    "CreatePos": 1123,
+    "StatementEnd": 1146,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -740,23 +883,23 @@
         "Name": {
           "Name": "r1_01293",
           "Unquoted": false,
-          "NamePos": 933,
-          "NameEnd": 941
+          "NamePos": 1135,
+          "NameEnd": 1143
         },
         "Scope": {
-          "LiteralPos": 943,
-          "LiteralEnd": 944,
+          "LiteralPos": 1145,
+          "LiteralEnd": 1146,
           "Literal": "%"
-        }
+        },
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": null
   },
   {
-    "CreatePos": 947,
-    "StatementEnd": 981,
+    "CreatePos": 1149,
+    "StatementEnd": 1183,
     "IfNotExists": false,
     "OrReplace": false,
     "RoleNames": [
@@ -764,17 +907,17 @@
         "Name": {
           "Name": "r2_01293",
           "Unquoted": false,
-          "NamePos": 959,
-          "NameEnd": 967
+          "NamePos": 1161,
+          "NameEnd": 1169
         },
         "Scope": {
-          "LiteralPos": 969,
-          "LiteralEnd": 981,
+          "LiteralPos": 1171,
+          "LiteralEnd": 1183,
           "Literal": "%.myhost.com"
-        }
+        },
+        "OnCluster": null
       }
     ],
-    "OnCluster": null,
     "AccessStorageType": null,
     "Settings": null
   }
diff --git a/parser/testdata/ddl/output/drop_role.sql.golden.json b/parser/testdata/ddl/output/drop_role.sql.golden.json
index 2f2deee..8d914a9 100644
--- a/parser/testdata/ddl/output/drop_role.sql.golden.json
+++ b/parser/testdata/ddl/output/drop_role.sql.golden.json
@@ -11,7 +11,8 @@
           "NamePos": 20,
           "NameEnd": 28
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -20,7 +21,8 @@
           "NamePos": 30,
           "NameEnd": 38
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -29,7 +31,8 @@
           "NamePos": 40,
           "NameEnd": 48
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -38,7 +41,8 @@
           "NamePos": 50,
           "NameEnd": 58
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -47,7 +51,8 @@
           "NamePos": 60,
           "NameEnd": 68
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -56,7 +61,8 @@
           "NamePos": 70,
           "NameEnd": 78
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -65,7 +71,8 @@
           "NamePos": 80,
           "NameEnd": 88
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -74,7 +81,8 @@
           "NamePos": 90,
           "NameEnd": 98
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       },
       {
         "Name": {
@@ -83,11 +91,11 @@
           "NamePos": 100,
           "NameEnd": 108
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
     "IfExists": true,
-    "OnCluster": null,
     "Modifier": "",
     "From": null
   },
@@ -103,11 +111,11 @@
           "NamePos": 130,
           "NameEnd": 146
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
     "IfExists": true,
-    "OnCluster": null,
     "Modifier": "",
     "From": null
   },
@@ -127,7 +135,8 @@
           "LiteralPos": 178,
           "LiteralEnd": 179,
           "Literal": "%"
-        }
+        },
+        "OnCluster": null
       },
       {
         "Name": {
@@ -135,11 +144,11 @@
           "LiteralEnd": 204,
           "Literal": "r2_01293@%.myhost.com"
         },
-        "Scope": null
+        "Scope": null,
+        "OnCluster": null
       }
     ],
     "IfExists": true,
-    "OnCluster": null,
     "Modifier": "",
     "From": null
   }