Skip to content

Commit fc5c95b

Browse files
kyleconroyclaude
andcommitted
Add IGNORE_DUP_KEY SUPPRESS_MESSAGES and COLUMNSTORE INDEX ONLINE support
- Add SuppressMessagesOption field to IgnoreDupKeyIndexOption - Add IGNORE_DUP_KEY = ON (SUPPRESS_MESSAGES = ON/OFF) parsing to CREATE INDEX - Add ONLINE option support to CREATE COLUMNSTORE INDEX statement - Add OnlineIndexOption case to columnStoreIndexOptionToJSON marshaling - Enable CreateIndexStatementTests140 and Baselines140_CreateIndexStatementTests140 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 21ce89d commit fc5c95b

File tree

5 files changed

+139
-9
lines changed

5 files changed

+139
-9
lines changed

ast/create_spatial_index_statement.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ func (d *DataCompressionOption) dropIndexOption() {}
8080

8181
// IgnoreDupKeyIndexOption represents the IGNORE_DUP_KEY option
8282
type IgnoreDupKeyIndexOption struct {
83-
OptionState string // "On", "Off"
84-
OptionKind string // "IgnoreDupKey"
83+
OptionState string // "On", "Off"
84+
OptionKind string // "IgnoreDupKey"
85+
SuppressMessagesOption *bool // true/false when SUPPRESS_MESSAGES specified
8586
}
8687

8788
func (i *IgnoreDupKeyIndexOption) node() {}

parser/marshal.go

Lines changed: 115 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6604,10 +6604,27 @@ func (p *Parser) parseColumnDefinition() (*ast.ColumnDefinition, error) {
66046604
optState = "Off"
66056605
}
66066606
p.nextToken()
6607-
indexDef.IndexOptions = append(indexDef.IndexOptions, &ast.IgnoreDupKeyIndexOption{
6607+
opt := &ast.IgnoreDupKeyIndexOption{
66086608
OptionKind: "IgnoreDupKey",
66096609
OptionState: optState,
6610-
})
6610+
}
6611+
// Check for optional (SUPPRESS_MESSAGES = ON/OFF)
6612+
if optState == "On" && p.curTok.Type == TokenLParen {
6613+
p.nextToken() // consume (
6614+
if strings.ToUpper(p.curTok.Literal) == "SUPPRESS_MESSAGES" {
6615+
p.nextToken() // consume SUPPRESS_MESSAGES
6616+
if p.curTok.Type == TokenEquals {
6617+
p.nextToken() // consume =
6618+
}
6619+
suppressVal := strings.ToUpper(p.curTok.Literal) == "ON"
6620+
opt.SuppressMessagesOption = &suppressVal
6621+
p.nextToken() // consume ON/OFF
6622+
}
6623+
if p.curTok.Type == TokenRParen {
6624+
p.nextToken() // consume )
6625+
}
6626+
}
6627+
indexDef.IndexOptions = append(indexDef.IndexOptions, opt)
66116628
} else if optionName == "FILLFACTOR" || optionName == "MAXDOP" {
66126629
// Integer expression options
66136630
optKind := "FillFactor"
@@ -11428,6 +11445,87 @@ func (p *Parser) parseCreateColumnStoreIndexStatement() (*ast.CreateColumnStoreI
1142811445
}
1142911446
stmt.IndexOptions = append(stmt.IndexOptions, opt)
1143011447

11448+
case "ONLINE":
11449+
p.nextToken() // consume ONLINE
11450+
if p.curTok.Type == TokenEquals {
11451+
p.nextToken() // consume =
11452+
}
11453+
valueStr := strings.ToUpper(p.curTok.Literal)
11454+
p.nextToken()
11455+
onlineOpt := &ast.OnlineIndexOption{
11456+
OptionKind: "Online",
11457+
OptionState: "On",
11458+
}
11459+
if valueStr == "OFF" {
11460+
onlineOpt.OptionState = "Off"
11461+
}
11462+
// Check for optional (WAIT_AT_LOW_PRIORITY (...))
11463+
if valueStr == "ON" && p.curTok.Type == TokenLParen {
11464+
p.nextToken() // consume (
11465+
if strings.ToUpper(p.curTok.Literal) == "WAIT_AT_LOW_PRIORITY" {
11466+
p.nextToken() // consume WAIT_AT_LOW_PRIORITY
11467+
lowPriorityOpt := &ast.OnlineIndexLowPriorityLockWaitOption{}
11468+
if p.curTok.Type == TokenLParen {
11469+
p.nextToken() // consume (
11470+
for p.curTok.Type != TokenRParen && p.curTok.Type != TokenEOF {
11471+
subOptName := strings.ToUpper(p.curTok.Literal)
11472+
if subOptName == "MAX_DURATION" {
11473+
p.nextToken() // consume MAX_DURATION
11474+
if p.curTok.Type == TokenEquals {
11475+
p.nextToken() // consume =
11476+
}
11477+
durVal, _ := p.parsePrimaryExpression()
11478+
unit := ""
11479+
if strings.ToUpper(p.curTok.Literal) == "MINUTES" {
11480+
unit = "Minutes"
11481+
p.nextToken()
11482+
} else if strings.ToUpper(p.curTok.Literal) == "SECONDS" {
11483+
unit = "Seconds"
11484+
p.nextToken()
11485+
}
11486+
lowPriorityOpt.Options = append(lowPriorityOpt.Options, &ast.LowPriorityLockWaitMaxDurationOption{
11487+
MaxDuration: durVal,
11488+
Unit: unit,
11489+
OptionKind: "MaxDuration",
11490+
})
11491+
} else if subOptName == "ABORT_AFTER_WAIT" {
11492+
p.nextToken() // consume ABORT_AFTER_WAIT
11493+
if p.curTok.Type == TokenEquals {
11494+
p.nextToken() // consume =
11495+
}
11496+
abortType := "None"
11497+
switch strings.ToUpper(p.curTok.Literal) {
11498+
case "NONE":
11499+
abortType = "None"
11500+
case "SELF":
11501+
abortType = "Self"
11502+
case "BLOCKERS":
11503+
abortType = "Blockers"
11504+
}
11505+
p.nextToken()
11506+
lowPriorityOpt.Options = append(lowPriorityOpt.Options, &ast.LowPriorityLockWaitAbortAfterWaitOption{
11507+
AbortAfterWait: abortType,
11508+
OptionKind: "AbortAfterWait",
11509+
})
11510+
} else {
11511+
break
11512+
}
11513+
if p.curTok.Type == TokenComma {
11514+
p.nextToken()
11515+
}
11516+
}
11517+
if p.curTok.Type == TokenRParen {
11518+
p.nextToken() // consume ) for WAIT_AT_LOW_PRIORITY options
11519+
}
11520+
}
11521+
onlineOpt.LowPriorityLockWaitOption = lowPriorityOpt
11522+
}
11523+
if p.curTok.Type == TokenRParen {
11524+
p.nextToken() // consume ) for ONLINE option
11525+
}
11526+
}
11527+
stmt.IndexOptions = append(stmt.IndexOptions, onlineOpt)
11528+
1143111529
default:
1143211530
// Skip unknown options
1143311531
p.nextToken()
@@ -13853,6 +13951,16 @@ func columnStoreIndexOptionToJSON(opt ast.IndexOption) jsonNode {
1385313951
node["PartitionRanges"] = ranges
1385413952
}
1385513953
return node
13954+
case *ast.OnlineIndexOption:
13955+
node := jsonNode{
13956+
"$type": "OnlineIndexOption",
13957+
"OptionState": o.OptionState,
13958+
"OptionKind": o.OptionKind,
13959+
}
13960+
if o.LowPriorityLockWaitOption != nil {
13961+
node["LowPriorityLockWaitOption"] = onlineIndexLowPriorityLockWaitOptionToJSON(o.LowPriorityLockWaitOption)
13962+
}
13963+
return node
1385613964
default:
1385713965
return jsonNode{"$type": "UnknownIndexOption"}
1385813966
}
@@ -14476,11 +14584,15 @@ func indexOptionToJSON(opt ast.IndexOption) jsonNode {
1447614584
}
1447714585
return node
1447814586
case *ast.IgnoreDupKeyIndexOption:
14479-
return jsonNode{
14587+
node := jsonNode{
1448014588
"$type": "IgnoreDupKeyIndexOption",
1448114589
"OptionState": o.OptionState,
1448214590
"OptionKind": o.OptionKind,
1448314591
}
14592+
if o.SuppressMessagesOption != nil {
14593+
node["SuppressMessagesOption"] = *o.SuppressMessagesOption
14594+
}
14595+
return node
1448414596
case *ast.OnlineIndexOption:
1448514597
node := jsonNode{
1448614598
"$type": "OnlineIndexOption",

parser/parse_statements.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10853,10 +10853,27 @@ func (p *Parser) parseCreateIndexOptions() []ast.IndexOption {
1085310853
Expression: &ast.IntegerLiteral{LiteralType: "Integer", Value: valueToken.Literal},
1085410854
})
1085510855
case "IGNORE_DUP_KEY":
10856-
options = append(options, &ast.IgnoreDupKeyIndexOption{
10856+
opt := &ast.IgnoreDupKeyIndexOption{
1085710857
OptionKind: "IgnoreDupKey",
1085810858
OptionState: p.capitalizeFirst(strings.ToLower(valueStr)),
10859-
})
10859+
}
10860+
// Check for optional (SUPPRESS_MESSAGES = ON/OFF)
10861+
if valueStr == "ON" && p.curTok.Type == TokenLParen {
10862+
p.nextToken() // consume (
10863+
if strings.ToUpper(p.curTok.Literal) == "SUPPRESS_MESSAGES" {
10864+
p.nextToken() // consume SUPPRESS_MESSAGES
10865+
if p.curTok.Type == TokenEquals {
10866+
p.nextToken() // consume =
10867+
}
10868+
suppressVal := strings.ToUpper(p.curTok.Literal) == "ON"
10869+
opt.SuppressMessagesOption = &suppressVal
10870+
p.nextToken() // consume ON/OFF
10871+
}
10872+
if p.curTok.Type == TokenRParen {
10873+
p.nextToken() // consume )
10874+
}
10875+
}
10876+
options = append(options, opt)
1086010877
case "DROP_EXISTING":
1086110878
options = append(options, &ast.IndexStateOption{
1086210879
OptionKind: "DropExisting",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)