Skip to content

Commit c34e702

Browse files
kyleconroyclaude
andcommitted
Add ON CLUSTER clause parsing to DELETE statement
Handle DELETE FROM table ON CLUSTER cluster WHERE ... syntax by parsing the ON CLUSTER clause between the table name and WHERE clause. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9564725 commit c34e702

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

ast/ast.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ type DeleteQuery struct {
729729
Position token.Position `json:"-"`
730730
Database string `json:"database,omitempty"`
731731
Table string `json:"table"`
732-
Partition Expression `json:"partition,omitempty"` // IN PARTITION clause
732+
OnCluster string `json:"on_cluster,omitempty"` // ON CLUSTER clause
733+
Partition Expression `json:"partition,omitempty"` // IN PARTITION clause
733734
Where Expression `json:"where,omitempty"`
734735
Settings []*SettingExpr `json:"settings,omitempty"`
735736
}

parser/parser.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6277,6 +6277,15 @@ func (p *Parser) parseDelete() *ast.DeleteQuery {
62776277
}
62786278
}
62796279

6280+
// Parse ON CLUSTER clause
6281+
if p.currentIs(token.ON) {
6282+
p.nextToken() // skip ON
6283+
if p.currentIs(token.CLUSTER) {
6284+
p.nextToken() // skip CLUSTER
6285+
del.OnCluster = p.parseIdentifierName()
6286+
}
6287+
}
6288+
62806289
// Parse IN PARTITION clause
62816290
if p.currentIs(token.IN) {
62826291
p.nextToken() // skip IN
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt8": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)