Skip to content

Commit 4359744

Browse files
committed
Add parser features and enable 8 more tests
Features added: - SAVE TRANSACTION legacy name format support (e.g., "5:a.b", "-100:[a].[b]") - DECLARE TABLE variable support with full table definition parsing - IncludeColumns marshaling for IndexDefinition - SetVariableStatement property/method syntax (dot and double-colon separators) - DROP EXTERNAL MODEL statement support - ALTER SERVER CONFIGURATION SET PROCESS AFFINITY support Tests enabled: - SaveTransactionStatementTests - BaselinesCommon_SaveTransactionStatementTests - DeclareTableStatementTests - BaselinesCommon_DeclareTableStatementTests - Baselines150_DeclareTableVariableTests150 - DeclareTableVariableTests150 - AlterServerConfigurationStatementTests - Baselines100_AlterServerConfigurationStatementTests
1 parent 3656485 commit 4359744

File tree

20 files changed

+988
-48
lines changed

20 files changed

+988
-48
lines changed

ast/alter_server_configuration_statement.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
package ast
22

3+
// AlterServerConfigurationStatement represents ALTER SERVER CONFIGURATION SET PROCESS AFFINITY statement
4+
type AlterServerConfigurationStatement struct {
5+
ProcessAffinity string // "CpuAuto", "Cpu", "NumaNode"
6+
ProcessAffinityRanges []*ProcessAffinityRange // for Cpu or NumaNode
7+
}
8+
9+
func (a *AlterServerConfigurationStatement) node() {}
10+
func (a *AlterServerConfigurationStatement) statement() {}
11+
12+
// ProcessAffinityRange represents a CPU or NUMA node range
13+
type ProcessAffinityRange struct {
14+
From ScalarExpression // IntegerLiteral
15+
To ScalarExpression // IntegerLiteral (optional)
16+
}
17+
18+
func (p *ProcessAffinityRange) node() {}
19+
320
// AlterServerConfigurationSetSoftNumaStatement represents ALTER SERVER CONFIGURATION SET SOFTNUMA statement
421
type AlterServerConfigurationSetSoftNumaStatement struct {
522
Options []*AlterServerConfigurationSoftNumaOption

ast/create_table_statement.go

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ type TableConstraint interface {
8383

8484
// IndexDefinition represents an index definition within CREATE TABLE
8585
type IndexDefinition struct {
86-
Name *Identifier
87-
Columns []*ColumnWithSortOrder
88-
Unique bool
89-
IndexType *IndexType
90-
IndexOptions []*IndexExpressionOption
86+
Name *Identifier
87+
Columns []*ColumnWithSortOrder
88+
Unique bool
89+
IndexType *IndexType
90+
IndexOptions []*IndexExpressionOption
91+
IncludeColumns []*ColumnReferenceExpression
9192
}
9293

9394
func (i *IndexDefinition) node() {}
@@ -108,3 +109,41 @@ const (
108109
SortOrderAscending
109110
SortOrderDescending
110111
)
112+
113+
// CheckConstraintDefinition represents a CHECK constraint
114+
type CheckConstraintDefinition struct {
115+
ConstraintIdentifier *Identifier
116+
CheckCondition BooleanExpression
117+
NotForReplication bool
118+
}
119+
120+
func (c *CheckConstraintDefinition) node() {}
121+
func (c *CheckConstraintDefinition) tableConstraint() {}
122+
func (c *CheckConstraintDefinition) constraintDefinition() {}
123+
124+
// UniqueConstraintDefinition represents a UNIQUE or PRIMARY KEY constraint
125+
type UniqueConstraintDefinition struct {
126+
ConstraintIdentifier *Identifier
127+
Clustered bool
128+
IsPrimaryKey bool
129+
Columns []*ColumnWithSortOrder
130+
IndexType *IndexType
131+
}
132+
133+
func (u *UniqueConstraintDefinition) node() {}
134+
func (u *UniqueConstraintDefinition) tableConstraint() {}
135+
func (u *UniqueConstraintDefinition) constraintDefinition() {}
136+
137+
// ForeignKeyConstraintDefinition represents a FOREIGN KEY constraint
138+
type ForeignKeyConstraintDefinition struct {
139+
ConstraintIdentifier *Identifier
140+
Columns []*Identifier
141+
ReferenceTableName *SchemaObjectName
142+
ReferencedColumns []*Identifier
143+
DeleteAction string
144+
UpdateAction string
145+
NotForReplication bool
146+
}
147+
148+
func (f *ForeignKeyConstraintDefinition) node() {}
149+
func (f *ForeignKeyConstraintDefinition) tableConstraint() {}

ast/declare_variable_statement.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ type DeclareVariableElement struct {
1616
Nullable *NullableConstraintDefinition `json:"Nullable,omitempty"`
1717
}
1818

19+
// DeclareTableVariableStatement represents a DECLARE @var TABLE statement.
20+
type DeclareTableVariableStatement struct {
21+
Body *DeclareTableVariableBody `json:"Body,omitempty"`
22+
}
23+
24+
func (d *DeclareTableVariableStatement) node() {}
25+
func (d *DeclareTableVariableStatement) statement() {}
26+
27+
// DeclareTableVariableBody represents the body of a table variable declaration.
28+
type DeclareTableVariableBody struct {
29+
VariableName *Identifier `json:"VariableName,omitempty"`
30+
AsDefined bool `json:"AsDefined,omitempty"`
31+
Definition *TableDefinition `json:"Definition,omitempty"`
32+
}
33+
34+
func (d *DeclareTableVariableBody) node() {}
35+
1936
// SqlDataTypeReference represents a SQL data type.
2037
type SqlDataTypeReference struct {
2138
SqlDataTypeOption string `json:"SqlDataTypeOption,omitempty"`

ast/drop_statements.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ type DropExternalResourcePoolStatement struct {
152152
func (s *DropExternalResourcePoolStatement) statement() {}
153153
func (s *DropExternalResourcePoolStatement) node() {}
154154

155+
// DropExternalModelStatement represents a DROP EXTERNAL MODEL statement
156+
type DropExternalModelStatement struct {
157+
IsIfExists bool
158+
Name *SchemaObjectName
159+
}
160+
161+
func (s *DropExternalModelStatement) statement() {}
162+
func (s *DropExternalModelStatement) node() {}
163+
155164
// DropWorkloadGroupStatement represents a DROP WORKLOAD GROUP statement
156165
type DropWorkloadGroupStatement struct {
157166
IsIfExists bool

ast/set_variable_statement.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package ast
22

33
// SetVariableStatement represents a SET @var = value statement.
44
type SetVariableStatement struct {
5-
Variable *VariableReference `json:"Variable,omitempty"`
6-
Expression ScalarExpression `json:"Expression,omitempty"`
7-
CursorDefinition *CursorDefinition `json:"CursorDefinition,omitempty"`
8-
AssignmentKind string `json:"AssignmentKind,omitempty"`
9-
SeparatorType string `json:"SeparatorType,omitempty"`
5+
Variable *VariableReference `json:"Variable,omitempty"`
6+
Expression ScalarExpression `json:"Expression,omitempty"`
7+
CursorDefinition *CursorDefinition `json:"CursorDefinition,omitempty"`
8+
AssignmentKind string `json:"AssignmentKind,omitempty"`
9+
SeparatorType string `json:"SeparatorType,omitempty"`
10+
Identifier *Identifier `json:"Identifier,omitempty"`
1011
FunctionCallExists bool `json:"FunctionCallExists,omitempty"`
12+
Parameters []ScalarExpression `json:"Parameters,omitempty"`
1113
}
1214

1315
func (s *SetVariableStatement) node() {}

0 commit comments

Comments
 (0)