Skip to content

Commit 6fef455

Browse files
authored
Add PartitionFunctionCall and double-colon expression support (#57)
1 parent e268b33 commit 6fef455

File tree

49 files changed

+2664
-158
lines changed

Some content is hidden

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

49 files changed

+2664
-158
lines changed

ast/alter_index_statement.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,32 @@ func (s *SelectiveXmlIndexPromotedPath) node() {}
2828

2929
// XmlNamespaces represents a WITH XMLNAMESPACES clause
3030
type XmlNamespaces struct {
31-
XmlNamespacesElements []*XmlNamespacesAliasElement
31+
XmlNamespacesElements []XmlNamespacesElement
3232
}
3333

3434
func (x *XmlNamespaces) node() {}
3535

36+
// XmlNamespacesElement is an interface for XML namespace elements
37+
type XmlNamespacesElement interface {
38+
xmlNamespacesElement()
39+
}
40+
3641
// XmlNamespacesAliasElement represents an alias element in XMLNAMESPACES
3742
type XmlNamespacesAliasElement struct {
3843
Identifier *Identifier
3944
String *StringLiteral
4045
}
4146

42-
func (x *XmlNamespacesAliasElement) node() {}
47+
func (x *XmlNamespacesAliasElement) node() {}
48+
func (x *XmlNamespacesAliasElement) xmlNamespacesElement() {}
49+
50+
// XmlNamespacesDefaultElement represents a default element in XMLNAMESPACES
51+
type XmlNamespacesDefaultElement struct {
52+
String *StringLiteral
53+
}
54+
55+
func (x *XmlNamespacesDefaultElement) node() {}
56+
func (x *XmlNamespacesDefaultElement) xmlNamespacesElement() {}
4357

4458
// PartitionSpecifier represents a partition specifier
4559
type PartitionSpecifier struct {

ast/broker_priority_statement.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package ast
2+
3+
// BrokerPriorityParameter represents a parameter in a BROKER PRIORITY statement.
4+
type BrokerPriorityParameter struct {
5+
IsDefaultOrAny string `json:"IsDefaultOrAny,omitempty"` // None, Default, Any
6+
ParameterType string `json:"ParameterType,omitempty"` // PriorityLevel, ContractName, RemoteServiceName, LocalServiceName
7+
ParameterValue *IdentifierOrValueExpression `json:"ParameterValue,omitempty"`
8+
}
9+
10+
func (*BrokerPriorityParameter) node() {}
11+
12+
// CreateBrokerPriorityStatement represents CREATE BROKER PRIORITY statement.
13+
type CreateBrokerPriorityStatement struct {
14+
Name *Identifier `json:"Name,omitempty"`
15+
BrokerPriorityParameters []*BrokerPriorityParameter `json:"BrokerPriorityParameters,omitempty"`
16+
}
17+
18+
func (*CreateBrokerPriorityStatement) node() {}
19+
func (*CreateBrokerPriorityStatement) statement() {}
20+
21+
// AlterBrokerPriorityStatement represents ALTER BROKER PRIORITY statement.
22+
type AlterBrokerPriorityStatement struct {
23+
Name *Identifier `json:"Name,omitempty"`
24+
BrokerPriorityParameters []*BrokerPriorityParameter `json:"BrokerPriorityParameters,omitempty"`
25+
}
26+
27+
func (*AlterBrokerPriorityStatement) node() {}
28+
func (*AlterBrokerPriorityStatement) statement() {}
29+
30+
// DropBrokerPriorityStatement represents DROP BROKER PRIORITY statement.
31+
type DropBrokerPriorityStatement struct {
32+
Name *Identifier `json:"Name,omitempty"`
33+
IsIfExists bool `json:"IsIfExists,omitempty"`
34+
}
35+
36+
func (*DropBrokerPriorityStatement) node() {}
37+
func (*DropBrokerPriorityStatement) statement() {}

ast/create_simple_statements.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,30 @@ func (s *CreateDatabaseStatement) statement() {}
2626

2727
// CreateLoginStatement represents a CREATE LOGIN statement.
2828
type CreateLoginStatement struct {
29-
Name *Identifier `json:"Name,omitempty"`
29+
Name *Identifier `json:"Name,omitempty"`
30+
Source CreateLoginSource `json:"Source,omitempty"`
3031
}
3132

3233
func (s *CreateLoginStatement) node() {}
3334
func (s *CreateLoginStatement) statement() {}
3435

36+
// CreateLoginSource is an interface for login sources
37+
type CreateLoginSource interface {
38+
createLoginSource()
39+
}
40+
41+
// ExternalCreateLoginSource represents FROM EXTERNAL PROVIDER source
42+
type ExternalCreateLoginSource struct {
43+
Options []PrincipalOption `json:"Options,omitempty"`
44+
}
45+
46+
func (s *ExternalCreateLoginSource) createLoginSource() {}
47+
48+
// PrincipalOption is an interface for principal options (SID, TYPE, etc.)
49+
type PrincipalOption interface {
50+
principalOptionNode()
51+
}
52+
3553
// ServiceContract represents a contract in CREATE/ALTER SERVICE.
3654
type ServiceContract struct {
3755
Name *Identifier `json:"Name,omitempty"`

ast/create_user_statement.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ type LiteralPrincipalOption struct {
2727
Value ScalarExpression
2828
}
2929

30-
func (o *LiteralPrincipalOption) userOptionNode() {}
30+
func (o *LiteralPrincipalOption) userOptionNode() {}
31+
func (o *LiteralPrincipalOption) principalOptionNode() {}
3132

3233
// IdentifierPrincipalOption represents an identifier-based user option
3334
type IdentifierPrincipalOption struct {
3435
OptionKind string
3536
Identifier *Identifier
3637
}
3738

38-
func (o *IdentifierPrincipalOption) userOptionNode() {}
39+
func (o *IdentifierPrincipalOption) userOptionNode() {}
40+
func (o *IdentifierPrincipalOption) principalOptionNode() {}
3941

4042
// DefaultSchemaPrincipalOption represents a default schema option
4143
type DefaultSchemaPrincipalOption struct {

ast/cte.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ast
22

33
// WithCtesAndXmlNamespaces represents the WITH clause containing CTEs and/or XML namespaces.
44
type WithCtesAndXmlNamespaces struct {
5+
XmlNamespaces *XmlNamespaces `json:"XmlNamespaces,omitempty"`
56
CommonTableExpressions []*CommonTableExpression `json:"CommonTableExpressions,omitempty"`
67
ChangeTrackingContext ScalarExpression `json:"ChangeTrackingContext,omitempty"`
78
}

ast/fulltext_stoplist_statement.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package ast
2+
3+
// CreateFullTextStopListStatement represents CREATE FULLTEXT STOPLIST statement
4+
type CreateFullTextStopListStatement struct {
5+
Name *Identifier `json:"Name,omitempty"`
6+
IsSystemStopList bool `json:"IsSystemStopList"`
7+
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
8+
SourceStopListName *Identifier `json:"SourceStopListName,omitempty"`
9+
Owner *Identifier `json:"Owner,omitempty"`
10+
}
11+
12+
func (s *CreateFullTextStopListStatement) node() {}
13+
func (s *CreateFullTextStopListStatement) statement() {}
14+
15+
// AlterFullTextStopListStatement represents ALTER FULLTEXT STOPLIST statement
16+
type AlterFullTextStopListStatement struct {
17+
Name *Identifier `json:"Name,omitempty"`
18+
Action *FullTextStopListAction `json:"Action,omitempty"`
19+
}
20+
21+
func (s *AlterFullTextStopListStatement) node() {}
22+
func (s *AlterFullTextStopListStatement) statement() {}
23+
24+
// FullTextStopListAction represents an action in ALTER FULLTEXT STOPLIST
25+
type FullTextStopListAction struct {
26+
IsAdd bool `json:"IsAdd"`
27+
IsAll bool `json:"IsAll"`
28+
StopWord *StringLiteral `json:"StopWord,omitempty"`
29+
LanguageTerm *IdentifierOrValueExpression `json:"LanguageTerm,omitempty"`
30+
}
31+
32+
func (a *FullTextStopListAction) node() {}
33+
34+
// DropFullTextStopListStatement represents DROP FULLTEXT STOPLIST statement
35+
type DropFullTextStopListStatement struct {
36+
Name *Identifier `json:"Name,omitempty"`
37+
IsIfExists bool `json:"IsIfExists"`
38+
}
39+
40+
func (s *DropFullTextStopListStatement) node() {}
41+
func (s *DropFullTextStopListStatement) statement() {}
42+
43+
// DropFullTextCatalogStatement represents DROP FULLTEXT CATALOG statement
44+
type DropFullTextCatalogStatement struct {
45+
Name *Identifier `json:"Name,omitempty"`
46+
}
47+
48+
func (s *DropFullTextCatalogStatement) node() {}
49+
func (s *DropFullTextCatalogStatement) statement() {}
50+
51+
// DropFulltextIndexStatement represents DROP FULLTEXT INDEX statement
52+
type DropFulltextIndexStatement struct {
53+
OnName *SchemaObjectName `json:"OnName,omitempty"`
54+
}
55+
56+
func (s *DropFulltextIndexStatement) node() {}
57+
func (s *DropFulltextIndexStatement) statement() {}

ast/fulltext_table_reference.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ast
2+
3+
// FullTextTableReference represents CONTAINSTABLE or FREETEXTTABLE in a FROM clause
4+
type FullTextTableReference struct {
5+
FullTextFunctionType string `json:"FullTextFunctionType,omitempty"` // Contains, FreeText
6+
TableName *SchemaObjectName `json:"TableName,omitempty"`
7+
Columns []*ColumnReferenceExpression `json:"Columns,omitempty"`
8+
SearchCondition ScalarExpression `json:"SearchCondition,omitempty"`
9+
TopN ScalarExpression `json:"TopN,omitempty"`
10+
Language ScalarExpression `json:"Language,omitempty"`
11+
PropertyName ScalarExpression `json:"PropertyName,omitempty"`
12+
Alias *Identifier `json:"Alias,omitempty"`
13+
ForPath bool `json:"ForPath"`
14+
}
15+
16+
func (*FullTextTableReference) node() {}
17+
func (*FullTextTableReference) tableReference() {}

ast/partition_function_call.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ast
2+
3+
// PartitionFunctionCall represents a $PARTITION function call.
4+
// Syntax: [database.]$PARTITION.function(args)
5+
type PartitionFunctionCall struct {
6+
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
7+
SchemaName *Identifier `json:"SchemaName,omitempty"`
8+
FunctionName *Identifier `json:"FunctionName,omitempty"`
9+
Parameters []ScalarExpression `json:"Parameters,omitempty"`
10+
}
11+
12+
func (*PartitionFunctionCall) node() {}
13+
func (*PartitionFunctionCall) scalarExpression() {}

ast/resource_pool_statement.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package ast
2+
3+
// CreateResourcePoolStatement represents a CREATE RESOURCE POOL statement
4+
type CreateResourcePoolStatement struct {
5+
Name *Identifier `json:"Name,omitempty"`
6+
ResourcePoolParameters []*ResourcePoolParameter `json:"ResourcePoolParameters,omitempty"`
7+
}
8+
9+
func (*CreateResourcePoolStatement) node() {}
10+
func (*CreateResourcePoolStatement) statement() {}
11+
12+
// AlterResourcePoolStatement represents an ALTER RESOURCE POOL statement
13+
type AlterResourcePoolStatement struct {
14+
Name *Identifier `json:"Name,omitempty"`
15+
ResourcePoolParameters []*ResourcePoolParameter `json:"ResourcePoolParameters,omitempty"`
16+
}
17+
18+
func (*AlterResourcePoolStatement) node() {}
19+
func (*AlterResourcePoolStatement) statement() {}
20+
21+
// ResourcePoolParameter represents a parameter in a resource pool statement
22+
type ResourcePoolParameter struct {
23+
ParameterType string `json:"ParameterType,omitempty"` // MinCpuPercent, MaxCpuPercent, CapCpuPercent, MinMemoryPercent, MaxMemoryPercent, MinIoPercent, MaxIoPercent, CapIoPercent, Affinity, etc.
24+
ParameterValue ScalarExpression `json:"ParameterValue,omitempty"`
25+
AffinitySpecification *ResourcePoolAffinitySpecification `json:"AffinitySpecification,omitempty"`
26+
}
27+
28+
// ResourcePoolAffinitySpecification represents an AFFINITY specification in a resource pool
29+
type ResourcePoolAffinitySpecification struct {
30+
AffinityType string `json:"AffinityType,omitempty"` // Scheduler, NumaNode
31+
IsAuto bool `json:"IsAuto"`
32+
PoolAffinityRanges []*LiteralRange `json:"PoolAffinityRanges,omitempty"`
33+
}
34+
35+
// LiteralRange represents a range of values (e.g., 50 TO 60)
36+
type LiteralRange struct {
37+
From ScalarExpression `json:"From,omitempty"`
38+
To ScalarExpression `json:"To,omitempty"`
39+
}

ast/rollup_grouping_specification.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,17 @@ type CompositeGroupingSpecification struct {
2323

2424
func (*CompositeGroupingSpecification) node() {}
2525
func (*CompositeGroupingSpecification) groupingSpecification() {}
26+
27+
// GrandTotalGroupingSpecification represents empty parentheses () which means grand total.
28+
type GrandTotalGroupingSpecification struct{}
29+
30+
func (*GrandTotalGroupingSpecification) node() {}
31+
func (*GrandTotalGroupingSpecification) groupingSpecification() {}
32+
33+
// GroupingSetsGroupingSpecification represents GROUP BY GROUPING SETS (...) syntax.
34+
type GroupingSetsGroupingSpecification struct {
35+
Arguments []GroupingSpecification `json:"Arguments,omitempty"`
36+
}
37+
38+
func (*GroupingSetsGroupingSpecification) node() {}
39+
func (*GroupingSetsGroupingSpecification) groupingSpecification() {}

0 commit comments

Comments
 (0)