Skip to content

Commit 8814f03

Browse files
committed
Add PARTITION and PART clause support for CHECK TABLE
The CHECK TABLE statement supports PARTITION and PART clauses to check specific partitions or parts. Added these fields to the AST and parser. Fixed test: 00961_check_table/stmt20
1 parent 2c892d1 commit 8814f03

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

ast/ast.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ type CheckQuery struct {
880880
Position token.Position `json:"-"`
881881
Database string `json:"database,omitempty"`
882882
Table string `json:"table"`
883+
Partition Expression `json:"partition,omitempty"`
884+
Part Expression `json:"part,omitempty"`
883885
Format string `json:"format,omitempty"`
884886
Settings []*SettingExpr `json:"settings,omitempty"`
885887
}

parser/parser.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7081,6 +7081,18 @@ func (p *Parser) parseCheck() *ast.CheckQuery {
70817081
check.Table = tableName
70827082
}
70837083

7084+
// Parse optional PARTITION clause
7085+
if p.currentIs(token.PARTITION) {
7086+
p.nextToken() // skip PARTITION
7087+
check.Partition = p.parseExpression(LOWEST)
7088+
}
7089+
7090+
// Parse optional PART clause
7091+
if p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "PART" {
7092+
p.nextToken() // skip PART
7093+
check.Part = p.parseExpression(LOWEST)
7094+
}
7095+
70847096
// Parse optional FORMAT
70857097
if p.currentIs(token.FORMAT) {
70867098
p.nextToken() // skip FORMAT
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt20": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)