Skip to content

Commit 03bf55c

Browse files
authored
Add NONCLUSTERED HASH and BUCKET_COUNT support for constraints (#55)
1 parent bc8ebcb commit 03bf55c

File tree

98 files changed

+3757
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+3757
-262
lines changed

ast/begin_dialog_statement.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package ast
2+
3+
// BeginDialogStatement represents a BEGIN DIALOG statement for SQL Server Service Broker.
4+
type BeginDialogStatement struct {
5+
IsConversation bool `json:"IsConversation,omitempty"`
6+
Handle ScalarExpression `json:"Handle,omitempty"`
7+
InitiatorServiceName *IdentifierOrValueExpression `json:"InitiatorServiceName,omitempty"`
8+
TargetServiceName ScalarExpression `json:"TargetServiceName,omitempty"`
9+
ContractName *IdentifierOrValueExpression `json:"ContractName,omitempty"`
10+
InstanceSpec ScalarExpression `json:"InstanceSpec,omitempty"`
11+
Options []DialogOption `json:"Options,omitempty"`
12+
}
13+
14+
func (s *BeginDialogStatement) node() {}
15+
func (s *BeginDialogStatement) statement() {}
16+
17+
// BeginConversationTimerStatement represents a BEGIN CONVERSATION TIMER statement.
18+
type BeginConversationTimerStatement struct {
19+
Handle ScalarExpression `json:"Handle,omitempty"`
20+
Timeout ScalarExpression `json:"Timeout,omitempty"`
21+
}
22+
23+
func (s *BeginConversationTimerStatement) node() {}
24+
func (s *BeginConversationTimerStatement) statement() {}
25+
26+
// DialogOption is an interface for dialog options.
27+
type DialogOption interface {
28+
dialogOption()
29+
}
30+
31+
// ScalarExpressionDialogOption represents a dialog option with a scalar expression value.
32+
type ScalarExpressionDialogOption struct {
33+
Value ScalarExpression `json:"Value,omitempty"`
34+
OptionKind string `json:"OptionKind,omitempty"` // RelatedConversation, RelatedConversationGroup, Lifetime
35+
}
36+
37+
func (o *ScalarExpressionDialogOption) dialogOption() {}
38+
39+
// OnOffDialogOption represents a dialog option with an ON/OFF value.
40+
type OnOffDialogOption struct {
41+
OptionState string `json:"OptionState,omitempty"` // On, Off
42+
OptionKind string `json:"OptionKind,omitempty"` // Encryption
43+
}
44+
45+
func (o *OnOffDialogOption) dialogOption() {}

ast/bulk_insert_statement.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type InsertBulkColumnDefinition struct {
2828

2929
// ColumnDefinitionBase represents a basic column definition.
3030
type ColumnDefinitionBase struct {
31-
ColumnIdentifier *Identifier `json:"ColumnIdentifier,omitempty"`
31+
ColumnIdentifier *Identifier `json:"ColumnIdentifier,omitempty"`
3232
DataType DataTypeReference `json:"DataType,omitempty"`
33+
Collation *Identifier `json:"Collation,omitempty"`
3334
}
3435

3536
// BulkInsertOption is the interface for bulk insert options.

ast/column_reference_expression.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package ast
44
type ColumnReferenceExpression struct {
55
ColumnType string `json:"ColumnType,omitempty"`
66
MultiPartIdentifier *MultiPartIdentifier `json:"MultiPartIdentifier,omitempty"`
7+
Collation *Identifier `json:"Collation,omitempty"`
78
}
89

910
func (*ColumnReferenceExpression) node() {}

ast/create_columnstore_index_statement.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package ast
22

33
// CreateColumnStoreIndexStatement represents a CREATE COLUMNSTORE INDEX statement
44
type CreateColumnStoreIndexStatement struct {
5-
Name *Identifier
6-
Clustered bool
7-
ClusteredExplicit bool // true if CLUSTERED or NONCLUSTERED was explicitly specified
8-
OnName *SchemaObjectName
9-
Columns []*ColumnReferenceExpression
10-
OrderedColumns []*ColumnReferenceExpression
11-
IndexOptions []IndexOption
12-
FilterClause BooleanExpression
13-
OnPartition *PartitionSpecifier
5+
Name *Identifier
6+
Clustered bool
7+
ClusteredExplicit bool // true if CLUSTERED or NONCLUSTERED was explicitly specified
8+
OnName *SchemaObjectName
9+
Columns []*ColumnReferenceExpression
10+
OrderedColumns []*ColumnReferenceExpression
11+
IndexOptions []IndexOption
12+
FilterClause BooleanExpression
13+
OnPartition *PartitionSpecifier
14+
OnFileGroupOrPartitionScheme *FileGroupOrPartitionScheme
1415
}
1516

1617
func (s *CreateColumnStoreIndexStatement) statement() {}

ast/create_procedure_statement.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ type CreateProcedureStatement struct {
1313
func (c *CreateProcedureStatement) node() {}
1414
func (c *CreateProcedureStatement) statement() {}
1515

16+
// CreateOrAlterProcedureStatement represents a CREATE OR ALTER PROCEDURE statement.
17+
type CreateOrAlterProcedureStatement struct {
18+
ProcedureReference *ProcedureReference
19+
Parameters []*ProcedureParameter
20+
StatementList *StatementList
21+
IsForReplication bool
22+
Options []ProcedureOptionBase
23+
MethodSpecifier *MethodSpecifier
24+
}
25+
26+
func (c *CreateOrAlterProcedureStatement) node() {}
27+
func (c *CreateOrAlterProcedureStatement) statement() {}
28+
1629
// ProcedureParameter represents a parameter in a procedure definition.
1730
type ProcedureParameter struct {
1831
VariableName *Identifier

ast/create_simple_statements.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,44 @@ func (s *CreateAssemblyStatement) statement() {}
122122

123123
// CreateCertificateStatement represents a CREATE CERTIFICATE statement.
124124
type CreateCertificateStatement struct {
125-
Name *Identifier `json:"Name,omitempty"`
125+
Name *Identifier `json:"Name,omitempty"`
126+
Owner *Identifier `json:"Owner,omitempty"`
127+
CertificateSource EncryptionSource `json:"CertificateSource,omitempty"`
128+
ActiveForBeginDialog string `json:"ActiveForBeginDialog,omitempty"` // "On", "Off", "NotSet"
129+
PrivateKeyPath *StringLiteral `json:"PrivateKeyPath,omitempty"`
130+
EncryptionPassword *StringLiteral `json:"EncryptionPassword,omitempty"`
131+
DecryptionPassword *StringLiteral `json:"DecryptionPassword,omitempty"`
132+
CertificateOptions []*CertificateOption `json:"CertificateOptions,omitempty"`
126133
}
127134

128135
func (s *CreateCertificateStatement) node() {}
129136
func (s *CreateCertificateStatement) statement() {}
130137

138+
// CertificateOption represents an option in a CREATE CERTIFICATE statement.
139+
type CertificateOption struct {
140+
Kind string `json:"Kind,omitempty"` // "Subject", "StartDate", "ExpiryDate"
141+
Value *StringLiteral `json:"Value,omitempty"`
142+
}
143+
144+
func (o *CertificateOption) node() {}
145+
146+
// AssemblyEncryptionSource represents a certificate source from an assembly.
147+
type AssemblyEncryptionSource struct {
148+
Assembly *Identifier `json:"Assembly,omitempty"`
149+
}
150+
151+
func (s *AssemblyEncryptionSource) node() {}
152+
func (s *AssemblyEncryptionSource) encryptionSource() {}
153+
154+
// FileEncryptionSource represents a certificate source from a file.
155+
type FileEncryptionSource struct {
156+
IsExecutable bool `json:"IsExecutable,omitempty"`
157+
File *StringLiteral `json:"File,omitempty"`
158+
}
159+
160+
func (s *FileEncryptionSource) node() {}
161+
func (s *FileEncryptionSource) encryptionSource() {}
162+
131163
// CreateAsymmetricKeyStatement represents a CREATE ASYMMETRIC KEY statement.
132164
type CreateAsymmetricKeyStatement struct {
133165
Name *Identifier `json:"Name,omitempty"`

ast/create_table_statement.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ type ColumnDefinition struct {
4949
IsHidden bool
5050
IsMasked bool
5151
Nullable *NullableConstraintDefinition
52+
StorageOptions *ColumnStorageOptions
5253
}
5354

5455
func (c *ColumnDefinition) node() {}
5556

57+
// ColumnStorageOptions represents storage options for a column (SPARSE, FILESTREAM)
58+
type ColumnStorageOptions struct {
59+
IsFileStream bool // true if FILESTREAM specified
60+
SparseOption string // "None", "Sparse", "ColumnSetForAllSparseColumns"
61+
}
62+
63+
func (c *ColumnStorageOptions) node() {}
64+
5665
// DataTypeReference is an interface for data type references
5766
type DataTypeReference interface {
5867
Node
@@ -166,3 +175,4 @@ type ForeignKeyConstraintDefinition struct {
166175

167176
func (f *ForeignKeyConstraintDefinition) node() {}
168177
func (f *ForeignKeyConstraintDefinition) tableConstraint() {}
178+
func (f *ForeignKeyConstraintDefinition) constraintDefinition() {}

ast/create_trigger_statement.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ type CreateTriggerStatement struct {
1616
func (s *CreateTriggerStatement) statement() {}
1717
func (s *CreateTriggerStatement) node() {}
1818

19+
// CreateOrAlterTriggerStatement represents a CREATE OR ALTER TRIGGER statement
20+
type CreateOrAlterTriggerStatement struct {
21+
Name *SchemaObjectName
22+
TriggerObject *TriggerObject
23+
TriggerType string // "For", "After", "InsteadOf"
24+
TriggerActions []*TriggerAction
25+
Options []TriggerOptionType
26+
WithAppend bool
27+
IsNotForReplication bool
28+
MethodSpecifier *MethodSpecifier
29+
StatementList *StatementList
30+
}
31+
32+
func (s *CreateOrAlterTriggerStatement) statement() {}
33+
func (s *CreateOrAlterTriggerStatement) node() {}
34+
1935
// EventTypeContainer represents an event type container
2036
type EventTypeContainer struct {
2137
EventType string `json:"EventType,omitempty"`

ast/create_view_statement.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,48 @@ type CreateViewStatement struct {
1313
func (c *CreateViewStatement) node() {}
1414
func (c *CreateViewStatement) statement() {}
1515

16-
// ViewOption represents a view option like SCHEMABINDING.
17-
type ViewOption struct {
16+
// CreateOrAlterViewStatement represents a CREATE OR ALTER VIEW statement.
17+
type CreateOrAlterViewStatement struct {
18+
SchemaObjectName *SchemaObjectName `json:"SchemaObjectName,omitempty"`
19+
Columns []*Identifier `json:"Columns,omitempty"`
20+
SelectStatement *SelectStatement `json:"SelectStatement,omitempty"`
21+
WithCheckOption bool `json:"WithCheckOption"`
22+
ViewOptions []ViewOption `json:"ViewOptions,omitempty"`
23+
IsMaterialized bool `json:"IsMaterialized"`
24+
}
25+
26+
func (c *CreateOrAlterViewStatement) node() {}
27+
func (c *CreateOrAlterViewStatement) statement() {}
28+
29+
// ViewOption is an interface for different view option types.
30+
type ViewOption interface {
31+
viewOption()
32+
}
33+
34+
// ViewStatementOption represents a simple view option like SCHEMABINDING.
35+
type ViewStatementOption struct {
1836
OptionKind string `json:"OptionKind,omitempty"`
1937
}
38+
39+
func (v *ViewStatementOption) viewOption() {}
40+
41+
// ViewDistributionOption represents a DISTRIBUTION option for materialized views.
42+
type ViewDistributionOption struct {
43+
OptionKind string `json:"OptionKind,omitempty"`
44+
Value *ViewHashDistributionPolicy `json:"Value,omitempty"`
45+
}
46+
47+
func (v *ViewDistributionOption) viewOption() {}
48+
49+
// ViewHashDistributionPolicy represents the hash distribution policy for materialized views.
50+
type ViewHashDistributionPolicy struct {
51+
DistributionColumn *Identifier `json:"DistributionColumn,omitempty"`
52+
DistributionColumns []*Identifier `json:"DistributionColumns,omitempty"`
53+
}
54+
55+
// ViewForAppendOption represents the FOR_APPEND option for materialized views.
56+
type ViewForAppendOption struct {
57+
OptionKind string `json:"OptionKind,omitempty"`
58+
}
59+
60+
func (v *ViewForAppendOption) viewOption() {}

ast/delete_statement.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ func (d *DeleteStatement) statement() {}
1212

1313
// DeleteSpecification contains the details of a DELETE.
1414
type DeleteSpecification struct {
15-
Target TableReference `json:"Target,omitempty"`
16-
FromClause *FromClause `json:"FromClause,omitempty"`
17-
WhereClause *WhereClause `json:"WhereClause,omitempty"`
15+
Target TableReference `json:"Target,omitempty"`
16+
FromClause *FromClause `json:"FromClause,omitempty"`
17+
WhereClause *WhereClause `json:"WhereClause,omitempty"`
18+
TopRowFilter *TopRowFilter `json:"TopRowFilter,omitempty"`
19+
OutputClause *OutputClause `json:"OutputClause,omitempty"`
20+
OutputIntoClause *OutputIntoClause `json:"OutputIntoClause,omitempty"`
1821
}

0 commit comments

Comments
 (0)