Skip to content

Commit 94eaa07

Browse files
committed
Add COMPRESS_ALL_ROW_GROUPS and COMPRESSION_DELAY index options
- Add COMPRESS_ALL_ROW_GROUPS option mapping for ALTER INDEX REORGANIZE - Implement CompressionDelayIndexOption parsing with TimeUnit support - Handle MINUTE/MINUTES time unit suffix for COMPRESSION_DELAY - Enable Baselines130_AlterIndexStatementTests130 and AlterIndexStatementTests130 tests
1 parent 17dba09 commit 94eaa07

4 files changed

Lines changed: 49 additions & 17 deletions

File tree

parser/marshal.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7469,13 +7469,31 @@ func (p *Parser) parseAlterIndexStatement() (*ast.AlterIndexStatement, error) {
74697469

74707470
if p.curTok.Type == TokenEquals {
74717471
p.nextToken()
7472-
valueStr := strings.ToUpper(p.curTok.Literal)
7472+
valueStr := p.curTok.Literal
7473+
valueUpper := strings.ToUpper(valueStr)
74737474
p.nextToken()
74747475

7475-
if valueStr == "ON" || valueStr == "OFF" {
7476+
if optionName == "COMPRESSION_DELAY" {
7477+
// Parse COMPRESSION_DELAY = value [MINUTE|MINUTES]
7478+
timeUnit := "Unitless"
7479+
nextUpper := strings.ToUpper(p.curTok.Literal)
7480+
if nextUpper == "MINUTE" {
7481+
timeUnit = "Minute"
7482+
p.nextToken()
7483+
} else if nextUpper == "MINUTES" {
7484+
timeUnit = "Minutes"
7485+
p.nextToken()
7486+
}
7487+
opt := &ast.CompressionDelayIndexOption{
7488+
OptionKind: "CompressionDelay",
7489+
Expression: &ast.IntegerLiteral{LiteralType: "Integer", Value: valueStr},
7490+
TimeUnit: timeUnit,
7491+
}
7492+
stmt.IndexOptions = append(stmt.IndexOptions, opt)
7493+
} else if valueUpper == "ON" || valueUpper == "OFF" {
74767494
opt := &ast.IndexStateOption{
74777495
OptionKind: p.getIndexOptionKind(optionName),
7478-
OptionState: p.capitalizeFirst(strings.ToLower(valueStr)),
7496+
OptionState: p.capitalizeFirst(strings.ToLower(valueUpper)),
74797497
}
74807498
stmt.IndexOptions = append(stmt.IndexOptions, opt)
74817499
} else {
@@ -7598,6 +7616,8 @@ func (p *Parser) getIndexOptionKind(optionName string) string {
75987616
"MAX_DURATION": "MaxDuration",
75997617
"WAIT_AT_LOW_PRIORITY": "WaitAtLowPriority",
76007618
"OPTIMIZE_FOR_SEQUENTIAL_KEY": "OptimizeForSequentialKey",
7619+
"COMPRESS_ALL_ROW_GROUPS": "CompressAllRowGroups",
7620+
"COMPRESSION_DELAY": "CompressionDelay",
76017621
}
76027622
if kind, ok := optionMap[optionName]; ok {
76037623
return kind
@@ -9311,6 +9331,16 @@ func indexOptionToJSON(opt ast.IndexOption) jsonNode {
93119331
"OptionState": o.OptionState,
93129332
"OptionKind": o.OptionKind,
93139333
}
9334+
case *ast.CompressionDelayIndexOption:
9335+
node := jsonNode{
9336+
"$type": "CompressionDelayIndexOption",
9337+
"OptionKind": o.OptionKind,
9338+
"TimeUnit": o.TimeUnit,
9339+
}
9340+
if o.Expression != nil {
9341+
node["Expression"] = scalarExpressionToJSON(o.Expression)
9342+
}
9343+
return node
93149344
default:
93159345
return jsonNode{"$type": "UnknownIndexOption"}
93169346
}

parser/parse_ddl.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,18 +2772,20 @@ func (p *Parser) parseAlterTableAlterIndexStatement(tableName *ast.SchemaObjectN
27722772

27732773
func convertIndexOptionKind(name string) string {
27742774
optionMap := map[string]string{
2775-
"BUCKET_COUNT": "BucketCount",
2776-
"PAD_INDEX": "PadIndex",
2777-
"FILLFACTOR": "FillFactor",
2778-
"SORT_IN_TEMPDB": "SortInTempDB",
2779-
"IGNORE_DUP_KEY": "IgnoreDupKey",
2780-
"STATISTICS_NORECOMPUTE": "StatisticsNoRecompute",
2781-
"DROP_EXISTING": "DropExisting",
2782-
"ONLINE": "Online",
2783-
"ALLOW_ROW_LOCKS": "AllowRowLocks",
2784-
"ALLOW_PAGE_LOCKS": "AllowPageLocks",
2785-
"MAXDOP": "MaxDop",
2786-
"DATA_COMPRESSION": "DataCompression",
2775+
"BUCKET_COUNT": "BucketCount",
2776+
"PAD_INDEX": "PadIndex",
2777+
"FILLFACTOR": "FillFactor",
2778+
"SORT_IN_TEMPDB": "SortInTempDB",
2779+
"IGNORE_DUP_KEY": "IgnoreDupKey",
2780+
"STATISTICS_NORECOMPUTE": "StatisticsNoRecompute",
2781+
"DROP_EXISTING": "DropExisting",
2782+
"ONLINE": "Online",
2783+
"ALLOW_ROW_LOCKS": "AllowRowLocks",
2784+
"ALLOW_PAGE_LOCKS": "AllowPageLocks",
2785+
"MAXDOP": "MaxDop",
2786+
"DATA_COMPRESSION": "DataCompression",
2787+
"COMPRESS_ALL_ROW_GROUPS": "CompressAllRowGroups",
2788+
"COMPRESSION_DELAY": "CompressionDelay",
27872789
}
27882790
if mapped, ok := optionMap[name]; ok {
27892791
return mapped
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)