Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
67abba5
Add NONCLUSTERED HASH and BUCKET_COUNT support for constraints
claude Jan 1, 2026
17dba09
Fix encoding for CreateMessageTypeStatementTests query.sql
claude Jan 1, 2026
94eaa07
Add COMPRESS_ALL_ROW_GROUPS and COMPRESSION_DELAY index options
claude Jan 1, 2026
d06e080
Add CREATE MATERIALIZED VIEW support with distribution and options
claude Jan 1, 2026
df16bfc
Add pseudo column parsing for $ACTION, $CUID, $ROWGUID
claude Jan 1, 2026
90ad1a1
Add comprehensive CREATE EVENT SESSION parsing support
claude Jan 1, 2026
c20a50e
Add PARTITION BY support in OVER clause for window functions
claude Jan 1, 2026
112028c
Fix CreateFulltextCatalogStatementTests parsing
claude Jan 1, 2026
070ed3e
Fix Baselines160_CreateProcedureStatementTests160 encoding
claude Jan 1, 2026
0f3199e
Add COLUMNSTORE index parsing improvements
claude Jan 1, 2026
0a9ea05
Add END CONVERSATION statement parsing
claude Jan 1, 2026
4fcb35e
Add COLLATE clause support for expressions
claude Jan 1, 2026
66f9ed5
Add SPARSE/FILESTREAM column storage options parsing
claude Jan 1, 2026
099fe84
Add TOP and OUTPUT clause parsing to DELETE statement
claude Jan 1, 2026
8939ee0
Add inline INDEX with INCLUDE clause parsing support
claude Jan 1, 2026
74b4588
Add BEGIN DIALOG and BEGIN CONVERSATION TIMER parsing
claude Jan 1, 2026
aa6a1d0
Fix ALTER INDEX option parsing issues
claude Jan 1, 2026
d12e922
Add comprehensive CREATE CERTIFICATE parsing
claude Jan 1, 2026
a3dbf52
Add IDENTITY function call and IDENTITYCOL/ROWGUIDCOL support
claude Jan 1, 2026
c48d32d
Add CREATE OR ALTER support for procedure, trigger, and view statements
claude Jan 1, 2026
7bcebdf
Add SQL 80-style CREATE INDEX WITH clause parsing
claude Jan 1, 2026
021f974
Add comprehensive EXECUTE statement parsing support
claude Jan 1, 2026
994ebcf
Add computed column constraints and XML CONTENT/DOCUMENT parsing
claude Jan 1, 2026
85a7a86
Add UTF-16 LE BOM support in lexer
claude Jan 1, 2026
c9defb8
Add TRIM function FROM keyword and function COLLATE support
claude Jan 1, 2026
4514c78
Add WAIT_AT_LOW_PRIORITY option for DROP INDEX statement
claude Jan 1, 2026
15a628f
Add comprehensive data type parsing support
claude Jan 1, 2026
50719c9
Add FOR clause parsing support for SELECT statements
claude Jan 1, 2026
81abf4b
Add comprehensive CREATE EXTERNAL TABLE parsing support
claude Jan 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions ast/begin_dialog_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ast

// BeginDialogStatement represents a BEGIN DIALOG statement for SQL Server Service Broker.
type BeginDialogStatement struct {
IsConversation bool `json:"IsConversation,omitempty"`
Handle ScalarExpression `json:"Handle,omitempty"`
InitiatorServiceName *IdentifierOrValueExpression `json:"InitiatorServiceName,omitempty"`
TargetServiceName ScalarExpression `json:"TargetServiceName,omitempty"`
ContractName *IdentifierOrValueExpression `json:"ContractName,omitempty"`
InstanceSpec ScalarExpression `json:"InstanceSpec,omitempty"`
Options []DialogOption `json:"Options,omitempty"`
}

func (s *BeginDialogStatement) node() {}
func (s *BeginDialogStatement) statement() {}

// BeginConversationTimerStatement represents a BEGIN CONVERSATION TIMER statement.
type BeginConversationTimerStatement struct {
Handle ScalarExpression `json:"Handle,omitempty"`
Timeout ScalarExpression `json:"Timeout,omitempty"`
}

func (s *BeginConversationTimerStatement) node() {}
func (s *BeginConversationTimerStatement) statement() {}

// DialogOption is an interface for dialog options.
type DialogOption interface {
dialogOption()
}

// ScalarExpressionDialogOption represents a dialog option with a scalar expression value.
type ScalarExpressionDialogOption struct {
Value ScalarExpression `json:"Value,omitempty"`
OptionKind string `json:"OptionKind,omitempty"` // RelatedConversation, RelatedConversationGroup, Lifetime
}

func (o *ScalarExpressionDialogOption) dialogOption() {}

// OnOffDialogOption represents a dialog option with an ON/OFF value.
type OnOffDialogOption struct {
OptionState string `json:"OptionState,omitempty"` // On, Off
OptionKind string `json:"OptionKind,omitempty"` // Encryption
}

func (o *OnOffDialogOption) dialogOption() {}
3 changes: 2 additions & 1 deletion ast/bulk_insert_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ type InsertBulkColumnDefinition struct {

// ColumnDefinitionBase represents a basic column definition.
type ColumnDefinitionBase struct {
ColumnIdentifier *Identifier `json:"ColumnIdentifier,omitempty"`
ColumnIdentifier *Identifier `json:"ColumnIdentifier,omitempty"`
DataType DataTypeReference `json:"DataType,omitempty"`
Collation *Identifier `json:"Collation,omitempty"`
}

// BulkInsertOption is the interface for bulk insert options.
Expand Down
1 change: 1 addition & 0 deletions ast/column_reference_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ast
type ColumnReferenceExpression struct {
ColumnType string `json:"ColumnType,omitempty"`
MultiPartIdentifier *MultiPartIdentifier `json:"MultiPartIdentifier,omitempty"`
Collation *Identifier `json:"Collation,omitempty"`
}

func (*ColumnReferenceExpression) node() {}
Expand Down
19 changes: 10 additions & 9 deletions ast/create_columnstore_index_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package ast

// CreateColumnStoreIndexStatement represents a CREATE COLUMNSTORE INDEX statement
type CreateColumnStoreIndexStatement struct {
Name *Identifier
Clustered bool
ClusteredExplicit bool // true if CLUSTERED or NONCLUSTERED was explicitly specified
OnName *SchemaObjectName
Columns []*ColumnReferenceExpression
OrderedColumns []*ColumnReferenceExpression
IndexOptions []IndexOption
FilterClause BooleanExpression
OnPartition *PartitionSpecifier
Name *Identifier
Clustered bool
ClusteredExplicit bool // true if CLUSTERED or NONCLUSTERED was explicitly specified
OnName *SchemaObjectName
Columns []*ColumnReferenceExpression
OrderedColumns []*ColumnReferenceExpression
IndexOptions []IndexOption
FilterClause BooleanExpression
OnPartition *PartitionSpecifier
OnFileGroupOrPartitionScheme *FileGroupOrPartitionScheme
}

func (s *CreateColumnStoreIndexStatement) statement() {}
Expand Down
13 changes: 13 additions & 0 deletions ast/create_procedure_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ type CreateProcedureStatement struct {
func (c *CreateProcedureStatement) node() {}
func (c *CreateProcedureStatement) statement() {}

// CreateOrAlterProcedureStatement represents a CREATE OR ALTER PROCEDURE statement.
type CreateOrAlterProcedureStatement struct {
ProcedureReference *ProcedureReference
Parameters []*ProcedureParameter
StatementList *StatementList
IsForReplication bool
Options []ProcedureOptionBase
MethodSpecifier *MethodSpecifier
}

func (c *CreateOrAlterProcedureStatement) node() {}
func (c *CreateOrAlterProcedureStatement) statement() {}

// ProcedureParameter represents a parameter in a procedure definition.
type ProcedureParameter struct {
VariableName *Identifier
Expand Down
34 changes: 33 additions & 1 deletion ast/create_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,44 @@ func (s *CreateAssemblyStatement) statement() {}

// CreateCertificateStatement represents a CREATE CERTIFICATE statement.
type CreateCertificateStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
CertificateSource EncryptionSource `json:"CertificateSource,omitempty"`
ActiveForBeginDialog string `json:"ActiveForBeginDialog,omitempty"` // "On", "Off", "NotSet"
PrivateKeyPath *StringLiteral `json:"PrivateKeyPath,omitempty"`
EncryptionPassword *StringLiteral `json:"EncryptionPassword,omitempty"`
DecryptionPassword *StringLiteral `json:"DecryptionPassword,omitempty"`
CertificateOptions []*CertificateOption `json:"CertificateOptions,omitempty"`
}

func (s *CreateCertificateStatement) node() {}
func (s *CreateCertificateStatement) statement() {}

// CertificateOption represents an option in a CREATE CERTIFICATE statement.
type CertificateOption struct {
Kind string `json:"Kind,omitempty"` // "Subject", "StartDate", "ExpiryDate"
Value *StringLiteral `json:"Value,omitempty"`
}

func (o *CertificateOption) node() {}

// AssemblyEncryptionSource represents a certificate source from an assembly.
type AssemblyEncryptionSource struct {
Assembly *Identifier `json:"Assembly,omitempty"`
}

func (s *AssemblyEncryptionSource) node() {}
func (s *AssemblyEncryptionSource) encryptionSource() {}

// FileEncryptionSource represents a certificate source from a file.
type FileEncryptionSource struct {
IsExecutable bool `json:"IsExecutable,omitempty"`
File *StringLiteral `json:"File,omitempty"`
}

func (s *FileEncryptionSource) node() {}
func (s *FileEncryptionSource) encryptionSource() {}

// CreateAsymmetricKeyStatement represents a CREATE ASYMMETRIC KEY statement.
type CreateAsymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down
10 changes: 10 additions & 0 deletions ast/create_table_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ type ColumnDefinition struct {
IsHidden bool
IsMasked bool
Nullable *NullableConstraintDefinition
StorageOptions *ColumnStorageOptions
}

func (c *ColumnDefinition) node() {}

// ColumnStorageOptions represents storage options for a column (SPARSE, FILESTREAM)
type ColumnStorageOptions struct {
IsFileStream bool // true if FILESTREAM specified
SparseOption string // "None", "Sparse", "ColumnSetForAllSparseColumns"
}

func (c *ColumnStorageOptions) node() {}

// DataTypeReference is an interface for data type references
type DataTypeReference interface {
Node
Expand Down Expand Up @@ -166,3 +175,4 @@ type ForeignKeyConstraintDefinition struct {

func (f *ForeignKeyConstraintDefinition) node() {}
func (f *ForeignKeyConstraintDefinition) tableConstraint() {}
func (f *ForeignKeyConstraintDefinition) constraintDefinition() {}
16 changes: 16 additions & 0 deletions ast/create_trigger_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ type CreateTriggerStatement struct {
func (s *CreateTriggerStatement) statement() {}
func (s *CreateTriggerStatement) node() {}

// CreateOrAlterTriggerStatement represents a CREATE OR ALTER TRIGGER statement
type CreateOrAlterTriggerStatement struct {
Name *SchemaObjectName
TriggerObject *TriggerObject
TriggerType string // "For", "After", "InsteadOf"
TriggerActions []*TriggerAction
Options []TriggerOptionType
WithAppend bool
IsNotForReplication bool
MethodSpecifier *MethodSpecifier
StatementList *StatementList
}

func (s *CreateOrAlterTriggerStatement) statement() {}
func (s *CreateOrAlterTriggerStatement) node() {}

// EventTypeContainer represents an event type container
type EventTypeContainer struct {
EventType string `json:"EventType,omitempty"`
Expand Down
45 changes: 43 additions & 2 deletions ast/create_view_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,48 @@ type CreateViewStatement struct {
func (c *CreateViewStatement) node() {}
func (c *CreateViewStatement) statement() {}

// ViewOption represents a view option like SCHEMABINDING.
type ViewOption struct {
// CreateOrAlterViewStatement represents a CREATE OR ALTER VIEW statement.
type CreateOrAlterViewStatement struct {
SchemaObjectName *SchemaObjectName `json:"SchemaObjectName,omitempty"`
Columns []*Identifier `json:"Columns,omitempty"`
SelectStatement *SelectStatement `json:"SelectStatement,omitempty"`
WithCheckOption bool `json:"WithCheckOption"`
ViewOptions []ViewOption `json:"ViewOptions,omitempty"`
IsMaterialized bool `json:"IsMaterialized"`
}

func (c *CreateOrAlterViewStatement) node() {}
func (c *CreateOrAlterViewStatement) statement() {}

// ViewOption is an interface for different view option types.
type ViewOption interface {
viewOption()
}

// ViewStatementOption represents a simple view option like SCHEMABINDING.
type ViewStatementOption struct {
OptionKind string `json:"OptionKind,omitempty"`
}

func (v *ViewStatementOption) viewOption() {}

// ViewDistributionOption represents a DISTRIBUTION option for materialized views.
type ViewDistributionOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Value *ViewHashDistributionPolicy `json:"Value,omitempty"`
}

func (v *ViewDistributionOption) viewOption() {}

// ViewHashDistributionPolicy represents the hash distribution policy for materialized views.
type ViewHashDistributionPolicy struct {
DistributionColumn *Identifier `json:"DistributionColumn,omitempty"`
DistributionColumns []*Identifier `json:"DistributionColumns,omitempty"`
}

// ViewForAppendOption represents the FOR_APPEND option for materialized views.
type ViewForAppendOption struct {
OptionKind string `json:"OptionKind,omitempty"`
}

func (v *ViewForAppendOption) viewOption() {}
9 changes: 6 additions & 3 deletions ast/delete_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ func (d *DeleteStatement) statement() {}

// DeleteSpecification contains the details of a DELETE.
type DeleteSpecification struct {
Target TableReference `json:"Target,omitempty"`
FromClause *FromClause `json:"FromClause,omitempty"`
WhereClause *WhereClause `json:"WhereClause,omitempty"`
Target TableReference `json:"Target,omitempty"`
FromClause *FromClause `json:"FromClause,omitempty"`
WhereClause *WhereClause `json:"WhereClause,omitempty"`
TopRowFilter *TopRowFilter `json:"TopRowFilter,omitempty"`
OutputClause *OutputClause `json:"OutputClause,omitempty"`
OutputIntoClause *OutputIntoClause `json:"OutputIntoClause,omitempty"`
}
31 changes: 31 additions & 0 deletions ast/drop_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,37 @@ type FileStreamOnDropIndexOption struct {
func (o *FileStreamOnDropIndexOption) node() {}
func (o *FileStreamOnDropIndexOption) dropIndexOption() {}

// WaitAtLowPriorityOption represents the WAIT_AT_LOW_PRIORITY option
type WaitAtLowPriorityOption struct {
Options []LowPriorityLockWaitOption
OptionKind string // WaitAtLowPriority
}

func (o *WaitAtLowPriorityOption) node() {}
func (o *WaitAtLowPriorityOption) dropIndexOption() {}

// LowPriorityLockWaitOption is the interface for options within WAIT_AT_LOW_PRIORITY
type LowPriorityLockWaitOption interface {
lowPriorityLockWaitOption()
}

// LowPriorityLockWaitMaxDurationOption represents MAX_DURATION option
type LowPriorityLockWaitMaxDurationOption struct {
MaxDuration *IntegerLiteral
Unit string // Minutes or Seconds
OptionKind string // MaxDuration
}

func (o *LowPriorityLockWaitMaxDurationOption) lowPriorityLockWaitOption() {}

// LowPriorityLockWaitAbortAfterWaitOption represents ABORT_AFTER_WAIT option
type LowPriorityLockWaitAbortAfterWaitOption struct {
AbortAfterWait string // None, Self, Blockers
OptionKind string // AbortAfterWait
}

func (o *LowPriorityLockWaitAbortAfterWaitOption) lowPriorityLockWaitOption() {}

// DropStatisticsStatement represents a DROP STATISTICS statement
type DropStatisticsStatement struct {
Objects []*SchemaObjectName
Expand Down
12 changes: 12 additions & 0 deletions ast/end_conversation_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ast

// EndConversationStatement represents END CONVERSATION statement
type EndConversationStatement struct {
Conversation ScalarExpression // The conversation handle
WithCleanup bool // true if WITH CLEANUP specified
ErrorCode ScalarExpression // optional error code with WITH ERROR
ErrorDescription ScalarExpression // optional error description with WITH ERROR
}

func (s *EndConversationStatement) statement() {}
func (s *EndConversationStatement) node() {}
Loading
Loading