Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
607b29f
Add BACKUP LOG and RESTORE statement parsing support
claude Dec 31, 2025
32a91b6
Add CREATE TYPE UDDT and UDT statement parsing support
claude Dec 31, 2025
db92d9a
Add partial support for CREATE TRIGGER options and BEGIN ATOMIC blocks
claude Dec 31, 2025
15462ef
Add BACKUP/RESTORE key statement parsing support
claude Dec 31, 2025
ec1883d
Enable CreateTypeStatementTests by preserving MaxLiteral value casing
claude Dec 31, 2025
6538173
Enable CreateHekatonTriggerStatementTest with asterisk wildcard and s…
claude Dec 31, 2025
6e7b955
Add CAST/CONVERT parsing and enable VECTOR/function tests
claude Dec 31, 2025
af66e4a
Add CREATE/ALTER SERVER AUDIT statement parsing support
claude Dec 31, 2025
f5929a2
Add ALTER FUNCTION statement parsing with default values and inline t…
claude Dec 31, 2025
642df74
Add CREATE FULLTEXT CATALOG statement parsing
claude Dec 31, 2025
9e6b8a4
Fix optimizer hint parsing for keyword tokens like ORDER GROUP
claude Dec 31, 2025
7e842a8
Add Unicode and double-quoted identifier support in lexer
claude Dec 31, 2025
c7223cb
Add WHERE clause and WITH options support for CREATE COLUMNSTORE INDEX
claude Dec 31, 2025
87b1ce6
Add SET clause options support for ALTER INDEX statement
claude Dec 31, 2025
0809244
Add TOP, OUTPUT, and OUTPUT INTO clause support for INSERT statement
claude Dec 31, 2025
2f1617e
Add ALTER EXTERNAL LIBRARY statement parsing support
claude Dec 31, 2025
d5562e5
Fix CREATE SEQUENCE to properly handle user-defined type aliases
claude Dec 31, 2025
638cfb5
Add table hints and TABLE HINT optimizer hint parsing support
claude Dec 31, 2025
165edf5
Add Azure-specific CREATE/ALTER DATABASE options support
claude Dec 31, 2025
18845ba
Add CREATE/DROP ASYMMETRIC KEY with provider support
claude Dec 31, 2025
562570a
Add CREATE EXTERNAL LIBRARY parsing with file options and language
claude Dec 31, 2025
2aacbc6
Add ALTER ASYMMETRIC KEY statement parsing
claude Dec 31, 2025
98edb19
Add PLATFORM support in CREATE EXTERNAL LIBRARY
claude Dec 31, 2025
ba6f706
Add CREATE TYPE AS TABLE support and computed column parsing
claude Dec 31, 2025
9fdc062
Add ON filegroup clause support for SELECT INTO statements
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
21 changes: 21 additions & 0 deletions ast/alter_database_set_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ func (o *OnOffDatabaseOption) createDatabaseOption() {}
func (i *IdentifierDatabaseOption) createDatabaseOption() {}
func (d *DelayedDurabilityDatabaseOption) createDatabaseOption() {}

// MaxSizeDatabaseOption represents a MAXSIZE option.
type MaxSizeDatabaseOption struct {
OptionKind string `json:"OptionKind,omitempty"`
MaxSize ScalarExpression `json:"MaxSize,omitempty"`
Units string `json:"Units,omitempty"` // "GB", "TB", etc.
}

func (m *MaxSizeDatabaseOption) node() {}
func (m *MaxSizeDatabaseOption) databaseOption() {}
func (m *MaxSizeDatabaseOption) createDatabaseOption() {}

// LiteralDatabaseOption represents a database option with a literal value (e.g., EDITION).
type LiteralDatabaseOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Value ScalarExpression `json:"Value,omitempty"`
}

func (l *LiteralDatabaseOption) node() {}
func (l *LiteralDatabaseOption) databaseOption() {}
func (l *LiteralDatabaseOption) createDatabaseOption() {}

// AlterDatabaseAddFileStatement represents ALTER DATABASE ... ADD FILE statement
type AlterDatabaseAddFileStatement struct {
DatabaseName *Identifier
Expand Down
4 changes: 2 additions & 2 deletions ast/alter_function_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ type TableValuedFunctionReturnType struct {

func (r *TableValuedFunctionReturnType) functionReturnTypeNode() {}

// SelectFunctionReturnType represents a SELECT function return type
// SelectFunctionReturnType represents a SELECT function return type (inline table-valued function)
type SelectFunctionReturnType struct {
// Simplified - will be expanded later
SelectStatement *SelectStatement
}

func (r *SelectFunctionReturnType) functionReturnTypeNode() {}
Expand Down
19 changes: 18 additions & 1 deletion ast/alter_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func (s *AlterApplicationRoleStatement) statement() {}

// AlterAsymmetricKeyStatement represents an ALTER ASYMMETRIC KEY statement.
type AlterAsymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Kind string `json:"Kind,omitempty"`
AttestedBy ScalarExpression `json:"AttestedBy,omitempty"`
EncryptionPassword ScalarExpression `json:"EncryptionPassword,omitempty"`
DecryptionPassword ScalarExpression `json:"DecryptionPassword,omitempty"`
}

func (s *AlterAsymmetricKeyStatement) node() {}
Expand Down Expand Up @@ -92,6 +96,19 @@ type AlterPartitionFunctionStatement struct {
func (s *AlterPartitionFunctionStatement) node() {}
func (s *AlterPartitionFunctionStatement) statement() {}

// CreateFullTextCatalogStatement represents a CREATE FULLTEXT CATALOG statement.
type CreateFullTextCatalogStatement struct {
Name *Identifier `json:"Name,omitempty"`
FileGroup *Identifier `json:"FileGroup,omitempty"`
Path ScalarExpression `json:"Path,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
Options []*OnOffFullTextCatalogOption `json:"Options,omitempty"`
IsDefault bool `json:"IsDefault"`
}

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

// AlterFulltextCatalogStatement represents an ALTER FULLTEXT CATALOG statement.
type AlterFulltextCatalogStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down
19 changes: 19 additions & 0 deletions ast/alter_table_alter_index_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,22 @@ type IndexExpressionOption struct {

func (i *IndexExpressionOption) indexOption() {}
func (i *IndexExpressionOption) node() {}

// CompressionDelayIndexOption represents a COMPRESSION_DELAY option
type CompressionDelayIndexOption struct {
Expression ScalarExpression
TimeUnit string // "Unitless", "Minute", "Minutes"
OptionKind string // "CompressionDelay"
}

func (c *CompressionDelayIndexOption) indexOption() {}
func (c *CompressionDelayIndexOption) node() {}

// OrderIndexOption represents an ORDER option for clustered columnstore indexes
type OrderIndexOption struct {
Columns []*ColumnReferenceExpression
OptionKind string // "Order"
}

func (o *OrderIndexOption) indexOption() {}
func (o *OrderIndexOption) node() {}
23 changes: 22 additions & 1 deletion ast/alter_trigger_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type AlterTriggerStatement struct {
TriggerObject *TriggerObject
TriggerType string // "For", "After", "InsteadOf"
TriggerActions []*TriggerAction
Options []*TriggerOption
Options []TriggerOptionType
WithAppend bool
IsNotForReplication bool
MethodSpecifier *MethodSpecifier
Expand All @@ -28,12 +28,33 @@ type TriggerAction struct {
EventTypeGroup *EventTypeContainer // For database/server events
}

// TriggerOptionType is the interface for trigger options
type TriggerOptionType interface {
triggerOption()
}

// TriggerOption represents a trigger option
type TriggerOption struct {
OptionKind string
OptionState string
}

func (o *TriggerOption) triggerOption() {}

// ExecuteAsClause represents an EXECUTE AS clause
type ExecuteAsClause struct {
ExecuteAsOption string // Caller, Self, Owner, or specific user
Principal ScalarExpression
}

// ExecuteAsTriggerOption represents an EXECUTE AS trigger option
type ExecuteAsTriggerOption struct {
OptionKind string // "ExecuteAsClause"
ExecuteAsClause *ExecuteAsClause
}

func (o *ExecuteAsTriggerOption) triggerOption() {}

// MethodSpecifier represents a CLR method specifier
type MethodSpecifier struct {
AssemblyName *Identifier
Expand Down
41 changes: 41 additions & 0 deletions ast/backup_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ func (s *BackupDatabaseStatement) statementNode() {}
func (s *BackupDatabaseStatement) statement() {}
func (s *BackupDatabaseStatement) node() {}

// BackupTransactionLogStatement represents a BACKUP LOG statement
type BackupTransactionLogStatement struct {
DatabaseName *IdentifierOrValueExpression
Devices []*DeviceInfo
Options []*BackupOption
}

func (s *BackupTransactionLogStatement) statementNode() {}
func (s *BackupTransactionLogStatement) statement() {}
func (s *BackupTransactionLogStatement) node() {}

// BackupOption represents a backup option
type BackupOption struct {
OptionKind string // Compression, NoCompression, StopOnError, ContinueAfterError, etc.
Expand All @@ -29,3 +40,33 @@ type BackupCertificateStatement struct {

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

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

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

// RestoreServiceMasterKeyStatement represents a RESTORE SERVICE MASTER KEY statement
type RestoreServiceMasterKeyStatement struct {
File ScalarExpression
Password ScalarExpression
IsForce bool
}

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

// RestoreMasterKeyStatement represents a RESTORE MASTER KEY statement
type RestoreMasterKeyStatement struct {
File ScalarExpression
Password ScalarExpression
EncryptionPassword ScalarExpression
IsForce bool
}

func (s *RestoreMasterKeyStatement) statement() {}
func (s *RestoreMasterKeyStatement) node() {}
30 changes: 30 additions & 0 deletions ast/begin_end_block_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ type BeginEndBlockStatement struct {
func (b *BeginEndBlockStatement) node() {}
func (b *BeginEndBlockStatement) statement() {}

// BeginEndAtomicBlockStatement represents a BEGIN ATOMIC...END block (for Hekaton/In-Memory OLTP).
type BeginEndAtomicBlockStatement struct {
Options []AtomicBlockOption
StatementList *StatementList
}

func (b *BeginEndAtomicBlockStatement) node() {}
func (b *BeginEndAtomicBlockStatement) statement() {}

// AtomicBlockOption is an interface for atomic block options.
type AtomicBlockOption interface {
atomicBlockOption()
}

// IdentifierAtomicBlockOption represents an atomic block option with an identifier value.
type IdentifierAtomicBlockOption struct {
OptionKind string
Value *Identifier
}

func (o *IdentifierAtomicBlockOption) atomicBlockOption() {}

// LiteralAtomicBlockOption represents an atomic block option with a literal value.
type LiteralAtomicBlockOption struct {
OptionKind string
Value ScalarExpression
}

func (o *LiteralAtomicBlockOption) atomicBlockOption() {}

// StatementList is a list of statements.
type StatementList struct {
Statements []Statement `json:"Statements,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion ast/create_columnstore_index_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type CreateColumnStoreIndexStatement struct {
Columns []*ColumnReferenceExpression
OrderedColumns []*ColumnReferenceExpression
IndexOptions []IndexOption
FilterClause ScalarExpression
FilterClause BooleanExpression
OnPartition *PartitionSpecifier
}

Expand Down
82 changes: 81 additions & 1 deletion ast/create_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type CreateDatabaseStatement struct {
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
Options []CreateDatabaseOption `json:"Options,omitempty"`
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
CopyOf *MultiPartIdentifier `json:"CopyOf,omitempty"` // For AS COPY OF syntax
}

func (s *CreateDatabaseStatement) node() {}
Expand Down Expand Up @@ -92,12 +93,63 @@ func (s *CreateCertificateStatement) statement() {}

// CreateAsymmetricKeyStatement represents a CREATE ASYMMETRIC KEY statement.
type CreateAsymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
KeySource EncryptionSource `json:"KeySource,omitempty"`
EncryptionAlgorithm string `json:"EncryptionAlgorithm,omitempty"`
Password ScalarExpression `json:"Password,omitempty"`
}

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

// EncryptionSource is an interface for key sources.
type EncryptionSource interface {
Node
encryptionSource()
}

// ProviderEncryptionSource represents a key source from a provider.
type ProviderEncryptionSource struct {
Name *Identifier `json:"Name,omitempty"`
KeyOptions []KeyOption `json:"KeyOptions,omitempty"`
}

func (p *ProviderEncryptionSource) node() {}
func (p *ProviderEncryptionSource) encryptionSource() {}

// KeyOption is an interface for key options.
type KeyOption interface {
Node
keyOption()
}

// AlgorithmKeyOption represents an ALGORITHM key option.
type AlgorithmKeyOption struct {
Algorithm string `json:"Algorithm,omitempty"`
OptionKind string `json:"OptionKind,omitempty"`
}

func (a *AlgorithmKeyOption) node() {}
func (a *AlgorithmKeyOption) keyOption() {}

// ProviderKeyNameKeyOption represents a PROVIDER_KEY_NAME key option.
type ProviderKeyNameKeyOption struct {
KeyName ScalarExpression `json:"KeyName,omitempty"`
OptionKind string `json:"OptionKind,omitempty"`
}

func (p *ProviderKeyNameKeyOption) node() {}
func (p *ProviderKeyNameKeyOption) keyOption() {}

// CreationDispositionKeyOption represents a CREATION_DISPOSITION key option.
type CreationDispositionKeyOption struct {
IsCreateNew bool `json:"IsCreateNew,omitempty"`
OptionKind string `json:"OptionKind,omitempty"`
}

func (c *CreationDispositionKeyOption) node() {}
func (c *CreationDispositionKeyOption) keyOption() {}

// CreateSymmetricKeyStatement represents a CREATE SYMMETRIC KEY statement.
type CreateSymmetricKeyStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down Expand Up @@ -206,6 +258,34 @@ type CreateTypeStatement struct {
func (s *CreateTypeStatement) node() {}
func (s *CreateTypeStatement) statement() {}

// CreateTypeUddtStatement represents a CREATE TYPE ... FROM statement (user-defined data type).
type CreateTypeUddtStatement struct {
Name *SchemaObjectName
DataType DataTypeReference
NullableConstraint *NullableConstraintDefinition
}

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

// CreateTypeUdtStatement represents a CREATE TYPE ... EXTERNAL NAME statement (CLR user-defined type).
type CreateTypeUdtStatement struct {
Name *SchemaObjectName
AssemblyName *AssemblyName
}

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

// CreateTypeTableStatement represents a CREATE TYPE ... AS TABLE statement (table type).
type CreateTypeTableStatement struct {
Name *SchemaObjectName `json:"Name,omitempty"`
Definition *TableDefinition `json:"Definition,omitempty"`
}

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

// CreateXmlIndexStatement represents a CREATE XML INDEX statement.
type CreateXmlIndexStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down
23 changes: 12 additions & 11 deletions ast/create_table_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ func (t *TableDefinition) node() {}

// ColumnDefinition represents a column definition in CREATE TABLE
type ColumnDefinition struct {
ColumnIdentifier *Identifier
DataType DataTypeReference
Collation *Identifier
DefaultConstraint *DefaultConstraintDefinition
IdentityOptions *IdentityOptions
Constraints []ConstraintDefinition
IsPersisted bool
IsRowGuidCol bool
IsHidden bool
IsMasked bool
Nullable *NullableConstraintDefinition
ColumnIdentifier *Identifier
DataType DataTypeReference
ComputedColumnExpression ScalarExpression
Collation *Identifier
DefaultConstraint *DefaultConstraintDefinition
IdentityOptions *IdentityOptions
Constraints []ConstraintDefinition
IsPersisted bool
IsRowGuidCol bool
IsHidden bool
IsMasked bool
Nullable *NullableConstraintDefinition
}

func (c *ColumnDefinition) node() {}
Expand Down
2 changes: 1 addition & 1 deletion ast/create_trigger_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type CreateTriggerStatement struct {
TriggerObject *TriggerObject
TriggerType string // "For", "After", "InsteadOf"
TriggerActions []*TriggerAction
Options []*TriggerOption
Options []TriggerOptionType
WithAppend bool
IsNotForReplication bool
MethodSpecifier *MethodSpecifier
Expand Down
10 changes: 10 additions & 0 deletions ast/drop_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,13 @@ type DropAssemblyStatement struct {

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

// DropAsymmetricKeyStatement represents a DROP ASYMMETRIC KEY statement
type DropAsymmetricKeyStatement struct {
IsIfExists bool `json:"IsIfExists"`
Name *Identifier `json:"Name,omitempty"`
RemoveProviderKey bool `json:"RemoveProviderKey"`
}

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