Skip to content

Commit cc208ea

Browse files
kyleconroyclaude
andcommitted
Parse MOVE PARTITION TO DISK/VOLUME syntax in ALTER statements
MOVE PARTITION can target a disk or volume in addition to a table. Added parsing for TO DISK 'disk_name' and TO VOLUME 'volume_name' syntax which were previously causing parse errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 353708c commit cc208ea

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

parser/parser.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5697,20 +5697,26 @@ func (p *Parser) parseAlterCommand() *ast.AlterCommand {
56975697
cmd.PartitionIsID = true
56985698
}
56995699
cmd.Partition = p.parseExpression(LOWEST)
5700-
// Parse TO TABLE destination
5700+
// Parse TO TABLE/DISK/VOLUME destination
57015701
if p.currentIs(token.TO) {
57025702
p.nextToken()
57035703
if p.currentIs(token.TABLE) {
57045704
p.nextToken()
5705-
}
5706-
// Parse destination table (can be qualified: database.table)
5707-
destName := p.parseIdentifierName()
5708-
if p.currentIs(token.DOT) {
5709-
p.nextToken()
5710-
cmd.ToDatabase = destName
5711-
cmd.ToTable = p.parseIdentifierName()
5712-
} else {
5713-
cmd.ToTable = destName
5705+
// Parse destination table (can be qualified: database.table)
5706+
destName := p.parseIdentifierName()
5707+
if p.currentIs(token.DOT) {
5708+
p.nextToken()
5709+
cmd.ToDatabase = destName
5710+
cmd.ToTable = p.parseIdentifierName()
5711+
} else {
5712+
cmd.ToTable = destName
5713+
}
5714+
} else if p.currentIs(token.IDENT) && (strings.ToUpper(p.current.Value) == "DISK" || strings.ToUpper(p.current.Value) == "VOLUME") {
5715+
// MOVE PARTITION ... TO DISK 'disk_name' or TO VOLUME 'volume_name'
5716+
p.nextToken() // skip DISK/VOLUME
5717+
if p.currentIs(token.STRING) {
5718+
p.nextToken() // skip the disk/volume name
5719+
}
57145720
}
57155721
}
57165722
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)