Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0807559
Add comprehensive optimizer hint parsing for OPTION clause
claude Dec 31, 2025
a5bb2e0
Add ADD/DROP SIGNATURE statement parsing support
claude Dec 31, 2025
daaa572
Add UPDATE statement TOP, OUTPUT, and FunctionCallSetClause support
claude Dec 31, 2025
805d225
Add CLR table-valued function parsing with ORDER hints and EXECUTE AS…
claude Dec 31, 2025
acb23a7
Add full ALTER ASSEMBLY statement parsing
claude Dec 31, 2025
578c420
Add MEMORY_OPTIMIZED table option parsing for CREATE TYPE AS TABLE
claude Dec 31, 2025
5f43069
Add ALTER SEARCH PROPERTY LIST statement parsing support
claude Dec 31, 2025
bb885c3
Add inline INDEX support for table types and fix identifier parsing
claude Dec 31, 2025
97cf740
Add comprehensive RESTORE statement option parsing
claude Dec 31, 2025
9a8a203
Fix ALTER ASSEMBLY statement parsing boundary handling
claude Dec 31, 2025
8936ec5
Add BACKUP MASTER KEY statement parsing support
claude Dec 31, 2025
01f1b59
Add symmetric key statement parsing with key options and encryption m…
claude Dec 31, 2025
82c5415
Add DATABASE ENCRYPTION KEY statement parsing support
claude Dec 31, 2025
ce5c053
Fix ALTER EXTERNAL LIBRARY to parse PLATFORM option
claude Dec 31, 2025
356e710
Add full ALTER TABLE ALTER COLUMN parsing support
claude Dec 31, 2025
ea35df6
Add UNIQUE/PRIMARY KEY constraint support for WITH and ON clauses
claude Dec 31, 2025
077a4e0
Add RESPECT NULLS / IGNORE NULLS window function syntax support
claude Dec 31, 2025
2232edc
Add ADD/DROP SENSITIVITY CLASSIFICATION statement support
claude Dec 31, 2025
918cd20
Add full CREATE INDEX statement parsing support
claude Dec 31, 2025
d34f1cb
Add OnlineIndexOption marshaling to indexOptionToJSON
claude Dec 31, 2025
da6a723
Fix UserLoginOptionType values to match expected format
claude Dec 31, 2025
f231603
Add NULL principal and other security statement improvements
claude Dec 31, 2025
97f1a27
Add column list support for permissions and fix multi-part identifier…
claude Dec 31, 2025
7f69410
Add full CREATE ASSEMBLY statement parsing
claude Dec 31, 2025
49059cc
Add table-valued function parsing in FROM clauses
claude Dec 31, 2025
66cc3bf
Add AUTO_DROP option parsing for CREATE STATISTICS
claude Dec 31, 2025
dc3641d
Add PREDICT table reference parsing and qualified star expressions
claude Dec 31, 2025
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
23 changes: 17 additions & 6 deletions ast/alter_function_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ func (s *AlterFunctionStatement) node() {}

// CreateFunctionStatement represents a CREATE FUNCTION statement
type CreateFunctionStatement struct {
Name *SchemaObjectName
Parameters []*ProcedureParameter
ReturnType FunctionReturnType
Options []FunctionOptionBase
StatementList *StatementList
Name *SchemaObjectName
Parameters []*ProcedureParameter
ReturnType FunctionReturnType
Options []FunctionOptionBase
StatementList *StatementList
OrderHint *OrderBulkInsertOption // For CLR table-valued functions
MethodSpecifier *MethodSpecifier // For CLR functions (AS EXTERNAL NAME)
}

func (s *CreateFunctionStatement) statement() {}
Expand All @@ -38,7 +40,7 @@ func (r *ScalarFunctionReturnType) functionReturnTypeNode() {}

// TableValuedFunctionReturnType represents a table-valued function return type
type TableValuedFunctionReturnType struct {
// Simplified - will be expanded later
DeclareTableVariableBody *DeclareTableVariableBody
}

func (r *TableValuedFunctionReturnType) functionReturnTypeNode() {}
Expand Down Expand Up @@ -73,6 +75,15 @@ type InlineFunctionOption struct {
func (o *InlineFunctionOption) node() {}
func (o *InlineFunctionOption) functionOption() {}

// ExecuteAsFunctionOption represents an EXECUTE AS function option
type ExecuteAsFunctionOption struct {
OptionKind string // "ExecuteAs"
ExecuteAs *ExecuteAsClause // The EXECUTE AS clause
}

func (o *ExecuteAsFunctionOption) node() {}
func (o *ExecuteAsFunctionOption) functionOption() {}

// CreateOrAlterFunctionStatement represents a CREATE OR ALTER FUNCTION statement
type CreateOrAlterFunctionStatement struct {
Name *SchemaObjectName
Expand Down
95 changes: 93 additions & 2 deletions ast/alter_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,91 @@ func (s *AlterRouteStatement) statement() {}

// AlterAssemblyStatement represents an ALTER ASSEMBLY statement.
type AlterAssemblyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Parameters []ScalarExpression `json:"Parameters,omitempty"` // FROM 'path' parameters
Options []AssemblyOptionBase `json:"Options,omitempty"`
AddFiles []*AddFileSpec `json:"AddFiles,omitempty"`
DropFiles []*StringLiteral `json:"DropFiles,omitempty"`
IsDropAll bool `json:"IsDropAll"`
}

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

// AddFileSpec represents an ADD FILE specification.
type AddFileSpec struct {
File ScalarExpression `json:"File,omitempty"` // The file path or binary literal
FileName *StringLiteral `json:"FileName,omitempty"` // Optional AS 'filename'
}

func (a *AddFileSpec) node() {}

// AssemblyOptionBase is an interface for assembly options.
type AssemblyOptionBase interface {
Node
assemblyOption()
}

// AssemblyOption represents a basic assembly option.
type AssemblyOption struct {
OptionKind string `json:"OptionKind,omitempty"` // "UncheckedData"
}

func (o *AssemblyOption) node() {}
func (o *AssemblyOption) assemblyOption() {}

// OnOffAssemblyOption represents a VISIBILITY = ON|OFF option.
type OnOffAssemblyOption struct {
OptionKind string `json:"OptionKind,omitempty"` // "Visibility"
OptionState string `json:"OptionState,omitempty"` // "On", "Off"
}

func (o *OnOffAssemblyOption) node() {}
func (o *OnOffAssemblyOption) assemblyOption() {}

// PermissionSetAssemblyOption represents a PERMISSION_SET option.
type PermissionSetAssemblyOption struct {
OptionKind string `json:"OptionKind,omitempty"` // "PermissionSet"
PermissionSetOption string `json:"PermissionSetOption,omitempty"` // "Safe", "ExternalAccess", "Unsafe"
}

func (o *PermissionSetAssemblyOption) node() {}
func (o *PermissionSetAssemblyOption) assemblyOption() {}

// AlterSearchPropertyListStatement represents an ALTER SEARCH PROPERTY LIST statement.
type AlterSearchPropertyListStatement struct {
Name *Identifier `json:"Name,omitempty"`
Action SearchPropertyListAction `json:"Action,omitempty"`
}

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

// SearchPropertyListAction is the interface for search property list actions.
type SearchPropertyListAction interface {
Node
searchPropertyListAction()
}

// AddSearchPropertyListAction represents an ADD action in ALTER SEARCH PROPERTY LIST.
type AddSearchPropertyListAction struct {
PropertyName *StringLiteral `json:"PropertyName,omitempty"`
Guid *StringLiteral `json:"Guid,omitempty"`
Id *IntegerLiteral `json:"Id,omitempty"`
Description *StringLiteral `json:"Description,omitempty"`
}

func (a *AddSearchPropertyListAction) node() {}
func (a *AddSearchPropertyListAction) searchPropertyListAction() {}

// DropSearchPropertyListAction represents a DROP action in ALTER SEARCH PROPERTY LIST.
type DropSearchPropertyListAction struct {
PropertyName *StringLiteral `json:"PropertyName,omitempty"`
}

func (a *DropSearchPropertyListAction) node() {}
func (a *DropSearchPropertyListAction) searchPropertyListAction() {}

// AlterEndpointStatement represents an ALTER ENDPOINT statement.
type AlterEndpointStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down Expand Up @@ -186,7 +265,9 @@ func (s *AlterFulltextIndexStatement) statement() {}

// AlterSymmetricKeyStatement represents an ALTER SYMMETRIC KEY statement.
type AlterSymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
IsAdd bool `json:"IsAdd"`
EncryptingMechanisms []*CryptoMechanism `json:"EncryptingMechanisms,omitempty"`
}

func (s *AlterSymmetricKeyStatement) node() {}
Expand All @@ -212,3 +293,13 @@ type RenameEntityStatement struct {

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

// AlterDatabaseEncryptionKeyStatement represents an ALTER DATABASE ENCRYPTION KEY statement.
type AlterDatabaseEncryptionKeyStatement struct {
Regenerate bool `json:"Regenerate"`
Algorithm string `json:"Algorithm,omitempty"`
Encryptor *CryptoMechanism `json:"Encryptor,omitempty"`
}

func (s *AlterDatabaseEncryptionKeyStatement) node() {}
func (s *AlterDatabaseEncryptionKeyStatement) statement() {}
13 changes: 7 additions & 6 deletions ast/alter_table_alter_column_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package ast

// AlterTableAlterColumnStatement represents ALTER TABLE ... ALTER COLUMN statement
type AlterTableAlterColumnStatement struct {
SchemaObjectName *SchemaObjectName
ColumnIdentifier *Identifier
DataType DataTypeReference
AlterTableAlterColumnOption string // "NoOptionDefined", "Add", "Drop", etc.
IsHidden bool
IsMasked bool
SchemaObjectName *SchemaObjectName
ColumnIdentifier *Identifier
DataType DataTypeReference
AlterTableAlterColumnOption string // "NoOptionDefined", "AddRowGuidCol", "DropRowGuidCol", "Null", "NotNull", etc.
IsHidden bool
Collation *Identifier
IsMasked bool
}

func (a *AlterTableAlterColumnStatement) node() {}
Expand Down
9 changes: 9 additions & 0 deletions ast/alter_table_set_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ type RetentionPeriodDefinition struct {
}

func (r *RetentionPeriodDefinition) node() {}

// MemoryOptimizedTableOption represents MEMORY_OPTIMIZED option
type MemoryOptimizedTableOption struct {
OptionKind string // "MemoryOptimized"
OptionState string // "On", "Off"
}

func (o *MemoryOptimizedTableOption) tableOption() {}
func (o *MemoryOptimizedTableOption) node() {}
9 changes: 9 additions & 0 deletions ast/backup_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ type BackupServiceMasterKeyStatement struct {
func (s *BackupServiceMasterKeyStatement) statement() {}
func (s *BackupServiceMasterKeyStatement) node() {}

// BackupMasterKeyStatement represents a BACKUP MASTER KEY statement
type BackupMasterKeyStatement struct {
File ScalarExpression
Password ScalarExpression
}

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

// RestoreServiceMasterKeyStatement represents a RESTORE SERVICE MASTER KEY statement
type RestoreServiceMasterKeyStatement struct {
File ScalarExpression
Expand Down
57 changes: 51 additions & 6 deletions ast/create_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ func (s *CreateEndpointStatement) statement() {}

// CreateAssemblyStatement represents a CREATE ASSEMBLY statement.
type CreateAssemblyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
Parameters []ScalarExpression `json:"Parameters,omitempty"`
Options []AssemblyOptionBase `json:"Options,omitempty"`
}

func (s *CreateAssemblyStatement) node() {}
Expand Down Expand Up @@ -184,6 +187,24 @@ type CreationDispositionKeyOption struct {
func (c *CreationDispositionKeyOption) node() {}
func (c *CreationDispositionKeyOption) keyOption() {}

// KeySourceKeyOption represents a KEY_SOURCE key option.
type KeySourceKeyOption struct {
PassPhrase ScalarExpression `json:"PassPhrase,omitempty"`
OptionKind string `json:"OptionKind,omitempty"`
}

func (k *KeySourceKeyOption) node() {}
func (k *KeySourceKeyOption) keyOption() {}

// IdentityValueKeyOption represents an IDENTITY_VALUE key option.
type IdentityValueKeyOption struct {
IdentityPhrase ScalarExpression `json:"IdentityPhrase,omitempty"`
OptionKind string `json:"OptionKind,omitempty"`
}

func (i *IdentityValueKeyOption) node() {}
func (i *IdentityValueKeyOption) keyOption() {}

// CryptoMechanism represents an encryption mechanism (CERTIFICATE, KEY, PASSWORD, etc.)
type CryptoMechanism struct {
CryptoMechanismType string `json:"CryptoMechanismType,omitempty"` // "Certificate", "SymmetricKey", "AsymmetricKey", "Password"
Expand All @@ -195,9 +216,10 @@ func (c *CryptoMechanism) node() {}

// CreateSymmetricKeyStatement represents a CREATE SYMMETRIC KEY statement.
type CreateSymmetricKeyStatement struct {
KeyOptions []KeyOption `json:"KeyOptions,omitempty"`
Provider *Identifier `json:"Provider,omitempty"`
Name *Identifier `json:"Name,omitempty"`
KeyOptions []KeyOption `json:"KeyOptions,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
Provider *Identifier `json:"Provider,omitempty"`
Name *Identifier `json:"Name,omitempty"`
EncryptingMechanisms []*CryptoMechanism `json:"EncryptingMechanisms,omitempty"`
}

Expand Down Expand Up @@ -289,8 +311,15 @@ func (s *CreatePartitionFunctionStatement) statement() {}

// CreateIndexStatement represents a CREATE INDEX statement.
type CreateIndexStatement struct {
Name *Identifier `json:"Name,omitempty"`
OnName *SchemaObjectName `json:"OnName,omitempty"`
Name *Identifier `json:"Name,omitempty"`
OnName *SchemaObjectName `json:"OnName,omitempty"`
Translated80SyntaxTo90 bool `json:"Translated80SyntaxTo90,omitempty"`
Unique bool `json:"Unique,omitempty"`
Clustered *bool `json:"Clustered,omitempty"` // nil = not specified, true = CLUSTERED, false = NONCLUSTERED
Columns []*ColumnWithSortOrder `json:"Columns,omitempty"`
IncludeColumns []*ColumnReferenceExpression `json:"IncludeColumns,omitempty"`
IndexOptions []IndexOption `json:"IndexOptions,omitempty"`
OnFileGroupOrPartitionScheme *FileGroupOrPartitionScheme `json:"OnFileGroupOrPartitionScheme,omitempty"`
}

func (s *CreateIndexStatement) node() {}
Expand Down Expand Up @@ -339,6 +368,7 @@ func (s *CreateTypeUdtStatement) statement() {}
type CreateTypeTableStatement struct {
Name *SchemaObjectName `json:"Name,omitempty"`
Definition *TableDefinition `json:"Definition,omitempty"`
Options []TableOption `json:"Options,omitempty"`
}

func (s *CreateTypeTableStatement) node() {}
Expand Down Expand Up @@ -387,3 +417,18 @@ type CreateEventNotificationStatement struct {

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

// CreateDatabaseEncryptionKeyStatement represents a CREATE DATABASE ENCRYPTION KEY statement.
type CreateDatabaseEncryptionKeyStatement struct {
Algorithm string `json:"Algorithm,omitempty"`
Encryptor *CryptoMechanism `json:"Encryptor,omitempty"`
}

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

// DropDatabaseEncryptionKeyStatement represents a DROP DATABASE ENCRYPTION KEY statement.
type DropDatabaseEncryptionKeyStatement struct{}

func (s *DropDatabaseEncryptionKeyStatement) node() {}
func (s *DropDatabaseEncryptionKeyStatement) statement() {}
15 changes: 9 additions & 6 deletions ast/create_table_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ColumnDefinition struct {
DefaultConstraint *DefaultConstraintDefinition
IdentityOptions *IdentityOptions
Constraints []ConstraintDefinition
Index *IndexDefinition
IsPersisted bool
IsRowGuidCol bool
IsHidden bool
Expand Down Expand Up @@ -137,12 +138,14 @@ func (c *CheckConstraintDefinition) constraintDefinition() {}

// UniqueConstraintDefinition represents a UNIQUE or PRIMARY KEY constraint
type UniqueConstraintDefinition struct {
ConstraintIdentifier *Identifier
Clustered bool
IsPrimaryKey bool
IsEnforced *bool // nil = not specified (default enforced), true = ENFORCED, false = NOT ENFORCED
Columns []*ColumnWithSortOrder
IndexType *IndexType
ConstraintIdentifier *Identifier
Clustered bool
IsPrimaryKey bool
IsEnforced *bool // nil = not specified (default enforced), true = ENFORCED, false = NOT ENFORCED
Columns []*ColumnWithSortOrder
IndexType *IndexType
IndexOptions []IndexOption
OnFileGroupOrPartitionScheme *FileGroupOrPartitionScheme
}

func (u *UniqueConstraintDefinition) node() {}
Expand Down
26 changes: 26 additions & 0 deletions ast/data_classification_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ast

// AddSensitivityClassificationStatement represents ADD SENSITIVITY CLASSIFICATION statement
type AddSensitivityClassificationStatement struct {
Columns []*ColumnReferenceExpression
Options []*SensitivityClassificationOption
}

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

// DropSensitivityClassificationStatement represents DROP SENSITIVITY CLASSIFICATION statement
type DropSensitivityClassificationStatement struct {
Columns []*ColumnReferenceExpression
}

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

// SensitivityClassificationOption represents an option in ADD SENSITIVITY CLASSIFICATION
type SensitivityClassificationOption struct {
Type string // "Label", "LabelId", "InformationType", "InformationTypeId", "Rank"
Value ScalarExpression // StringLiteral or IdentifierLiteral
}

func (o *SensitivityClassificationOption) node() {}
1 change: 1 addition & 0 deletions ast/drop_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type OnlineIndexOption struct {

func (o *OnlineIndexOption) node() {}
func (o *OnlineIndexOption) dropIndexOption() {}
func (o *OnlineIndexOption) indexOption() {}

// MoveToDropIndexOption represents the MOVE TO option
type MoveToDropIndexOption struct {
Expand Down
15 changes: 8 additions & 7 deletions ast/function_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ func (*WithinGroupClause) node() {}

// FunctionCall represents a function call.
type FunctionCall struct {
CallTarget CallTarget `json:"CallTarget,omitempty"`
FunctionName *Identifier `json:"FunctionName,omitempty"`
Parameters []ScalarExpression `json:"Parameters,omitempty"`
UniqueRowFilter string `json:"UniqueRowFilter,omitempty"`
WithinGroupClause *WithinGroupClause `json:"WithinGroupClause,omitempty"`
OverClause *OverClause `json:"OverClause,omitempty"`
WithArrayWrapper bool `json:"WithArrayWrapper,omitempty"`
CallTarget CallTarget `json:"CallTarget,omitempty"`
FunctionName *Identifier `json:"FunctionName,omitempty"`
Parameters []ScalarExpression `json:"Parameters,omitempty"`
UniqueRowFilter string `json:"UniqueRowFilter,omitempty"`
WithinGroupClause *WithinGroupClause `json:"WithinGroupClause,omitempty"`
OverClause *OverClause `json:"OverClause,omitempty"`
IgnoreRespectNulls []*Identifier `json:"IgnoreRespectNulls,omitempty"`
WithArrayWrapper bool `json:"WithArrayWrapper,omitempty"`
}

func (*FunctionCall) node() {}
Expand Down
Loading
Loading