Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
206 changes: 206 additions & 0 deletions doris/ast/ddlnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,209 @@ type DropViewStmt struct {
func (n *DropViewStmt) Tag() NodeTag { return T_DropViewStmt }

var _ Node = (*DropViewStmt)(nil)

// ---------------------------------------------------------------------------
// WORKLOAD GROUP DDL nodes (T5.4)
// ---------------------------------------------------------------------------

// CreateWorkloadGroupStmt represents:
//
// CREATE WORKLOAD GROUP [IF NOT EXISTS] name PROPERTIES(...)
type CreateWorkloadGroupStmt struct {
Name string
IfNotExists bool
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *CreateWorkloadGroupStmt) Tag() NodeTag { return T_CreateWorkloadGroupStmt }

var _ Node = (*CreateWorkloadGroupStmt)(nil)

// AlterWorkloadGroupStmt represents:
//
// ALTER WORKLOAD GROUP name PROPERTIES(...)
type AlterWorkloadGroupStmt struct {
Name string
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *AlterWorkloadGroupStmt) Tag() NodeTag { return T_AlterWorkloadGroupStmt }

var _ Node = (*AlterWorkloadGroupStmt)(nil)

// DropWorkloadGroupStmt represents:
//
// DROP WORKLOAD GROUP [IF EXISTS] name
type DropWorkloadGroupStmt struct {
Name string
IfExists bool
Loc Loc
}

// Tag implements Node.
func (n *DropWorkloadGroupStmt) Tag() NodeTag { return T_DropWorkloadGroupStmt }

var _ Node = (*DropWorkloadGroupStmt)(nil)

// ---------------------------------------------------------------------------
// WORKLOAD POLICY DDL nodes (T5.4)
// ---------------------------------------------------------------------------

// WorkloadPolicyItem holds a raw-text capture of one condition or action item
// from a WORKLOAD POLICY CONDITIONS/ACTIONS clause.
type WorkloadPolicyItem struct {
RawText string
Loc Loc
}

// Tag implements Node.
func (n *WorkloadPolicyItem) Tag() NodeTag { return T_WorkloadPolicyItem }

var _ Node = (*WorkloadPolicyItem)(nil)

// CreateWorkloadPolicyStmt represents:
//
// CREATE WORKLOAD POLICY [IF NOT EXISTS] name
// CONDITIONS(condition_list)
// ACTIONS(action_list)
// [PROPERTIES(...)]
type CreateWorkloadPolicyStmt struct {
Name string
IfNotExists bool
Conditions []*WorkloadPolicyItem
Actions []*WorkloadPolicyItem
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *CreateWorkloadPolicyStmt) Tag() NodeTag { return T_CreateWorkloadPolicyStmt }

var _ Node = (*CreateWorkloadPolicyStmt)(nil)

// AlterWorkloadPolicyStmt represents:
//
// ALTER WORKLOAD POLICY name PROPERTIES(...)
type AlterWorkloadPolicyStmt struct {
Name string
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *AlterWorkloadPolicyStmt) Tag() NodeTag { return T_AlterWorkloadPolicyStmt }

var _ Node = (*AlterWorkloadPolicyStmt)(nil)

// DropWorkloadPolicyStmt represents:
//
// DROP WORKLOAD POLICY [IF EXISTS] name
type DropWorkloadPolicyStmt struct {
Name string
IfExists bool
Loc Loc
}

// Tag implements Node.
func (n *DropWorkloadPolicyStmt) Tag() NodeTag { return T_DropWorkloadPolicyStmt }

var _ Node = (*DropWorkloadPolicyStmt)(nil)

// ---------------------------------------------------------------------------
// RESOURCE DDL nodes (T5.4)
// ---------------------------------------------------------------------------

// CreateResourceStmt represents:
//
// CREATE [EXTERNAL] RESOURCE [IF NOT EXISTS] name PROPERTIES(...)
type CreateResourceStmt struct {
Name string
IfNotExists bool
External bool
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *CreateResourceStmt) Tag() NodeTag { return T_CreateResourceStmt }

var _ Node = (*CreateResourceStmt)(nil)

// AlterResourceStmt represents:
//
// ALTER RESOURCE name PROPERTIES(...)
type AlterResourceStmt struct {
Name string
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *AlterResourceStmt) Tag() NodeTag { return T_AlterResourceStmt }

var _ Node = (*AlterResourceStmt)(nil)

// DropResourceStmt represents:
//
// DROP RESOURCE [IF EXISTS] name
type DropResourceStmt struct {
Name string
IfExists bool
Loc Loc
}

// Tag implements Node.
func (n *DropResourceStmt) Tag() NodeTag { return T_DropResourceStmt }

var _ Node = (*DropResourceStmt)(nil)

// ---------------------------------------------------------------------------
// SQL BLOCK RULE DDL nodes (T5.4)
// ---------------------------------------------------------------------------

// CreateSQLBlockRuleStmt represents:
//
// CREATE SQL_BLOCK_RULE [IF NOT EXISTS] name PROPERTIES(...)
type CreateSQLBlockRuleStmt struct {
Name string
IfNotExists bool
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *CreateSQLBlockRuleStmt) Tag() NodeTag { return T_CreateSQLBlockRuleStmt }

var _ Node = (*CreateSQLBlockRuleStmt)(nil)

// AlterSQLBlockRuleStmt represents:
//
// ALTER SQL_BLOCK_RULE name PROPERTIES(...)
type AlterSQLBlockRuleStmt struct {
Name string
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *AlterSQLBlockRuleStmt) Tag() NodeTag { return T_AlterSQLBlockRuleStmt }

var _ Node = (*AlterSQLBlockRuleStmt)(nil)

// DropSQLBlockRuleStmt represents:
//
// DROP SQL_BLOCK_RULE [IF EXISTS] name
type DropSQLBlockRuleStmt struct {
Name string
IfExists bool
Loc Loc
}

// Tag implements Node.
func (n *DropSQLBlockRuleStmt) Tag() NodeTag { return T_DropSQLBlockRuleStmt }

var _ Node = (*DropSQLBlockRuleStmt)(nil)
26 changes: 26 additions & 0 deletions doris/ast/loc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ func NodeLoc(n Node) Loc {
return v.Loc
case *MergeClause:
return v.Loc
case *CreateWorkloadGroupStmt:
return v.Loc
case *AlterWorkloadGroupStmt:
return v.Loc
case *DropWorkloadGroupStmt:
return v.Loc
case *WorkloadPolicyItem:
return v.Loc
case *CreateWorkloadPolicyStmt:
return v.Loc
case *AlterWorkloadPolicyStmt:
return v.Loc
case *DropWorkloadPolicyStmt:
return v.Loc
case *CreateResourceStmt:
return v.Loc
case *AlterResourceStmt:
return v.Loc
case *DropResourceStmt:
return v.Loc
case *CreateSQLBlockRuleStmt:
return v.Loc
case *AlterSQLBlockRuleStmt:
return v.Loc
case *DropSQLBlockRuleStmt:
return v.Loc
default:
return NoLoc()
}
Expand Down
67 changes: 67 additions & 0 deletions doris/ast/nodetags.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,47 @@ const (

// T_MergeClause is the tag for *MergeClause (one WHEN clause inside MERGE).
T_MergeClause

// Workload management DDL nodes (T5.4).

// T_CreateWorkloadGroupStmt is the tag for *CreateWorkloadGroupStmt.
T_CreateWorkloadGroupStmt

// T_AlterWorkloadGroupStmt is the tag for *AlterWorkloadGroupStmt.
T_AlterWorkloadGroupStmt

// T_DropWorkloadGroupStmt is the tag for *DropWorkloadGroupStmt.
T_DropWorkloadGroupStmt

// T_WorkloadPolicyItem is the tag for *WorkloadPolicyItem.
T_WorkloadPolicyItem

// T_CreateWorkloadPolicyStmt is the tag for *CreateWorkloadPolicyStmt.
T_CreateWorkloadPolicyStmt

// T_AlterWorkloadPolicyStmt is the tag for *AlterWorkloadPolicyStmt.
T_AlterWorkloadPolicyStmt

// T_DropWorkloadPolicyStmt is the tag for *DropWorkloadPolicyStmt.
T_DropWorkloadPolicyStmt

// T_CreateResourceStmt is the tag for *CreateResourceStmt.
T_CreateResourceStmt

// T_AlterResourceStmt is the tag for *AlterResourceStmt.
T_AlterResourceStmt

// T_DropResourceStmt is the tag for *DropResourceStmt.
T_DropResourceStmt

// T_CreateSQLBlockRuleStmt is the tag for *CreateSQLBlockRuleStmt.
T_CreateSQLBlockRuleStmt

// T_AlterSQLBlockRuleStmt is the tag for *AlterSQLBlockRuleStmt.
T_AlterSQLBlockRuleStmt

// T_DropSQLBlockRuleStmt is the tag for *DropSQLBlockRuleStmt.
T_DropSQLBlockRuleStmt
)

// String returns a human-readable representation of the tag.
Expand Down Expand Up @@ -327,6 +368,32 @@ func (t NodeTag) String() string {
return "MergeStmt"
case T_MergeClause:
return "MergeClause"
case T_CreateWorkloadGroupStmt:
return "CreateWorkloadGroupStmt"
case T_AlterWorkloadGroupStmt:
return "AlterWorkloadGroupStmt"
case T_DropWorkloadGroupStmt:
return "DropWorkloadGroupStmt"
case T_WorkloadPolicyItem:
return "WorkloadPolicyItem"
case T_CreateWorkloadPolicyStmt:
return "CreateWorkloadPolicyStmt"
case T_AlterWorkloadPolicyStmt:
return "AlterWorkloadPolicyStmt"
case T_DropWorkloadPolicyStmt:
return "DropWorkloadPolicyStmt"
case T_CreateResourceStmt:
return "CreateResourceStmt"
case T_AlterResourceStmt:
return "AlterResourceStmt"
case T_DropResourceStmt:
return "DropResourceStmt"
case T_CreateSQLBlockRuleStmt:
return "CreateSQLBlockRuleStmt"
case T_AlterSQLBlockRuleStmt:
return "AlterSQLBlockRuleStmt"
case T_DropSQLBlockRuleStmt:
return "DropSQLBlockRuleStmt"
default:
return "Unknown"
}
Expand Down
50 changes: 50 additions & 0 deletions doris/ast/walk_children.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,55 @@ func walkChildren(v Visitor, node Node) {
Walk(v, val)
}
}

// Workload management DDL nodes (T5.4).
case *CreateWorkloadGroupStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *AlterWorkloadGroupStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *DropWorkloadGroupStmt:
// leaf-ish node, no Node children
case *WorkloadPolicyItem:
// leaf node, raw text only
case *CreateWorkloadPolicyStmt:
for _, c := range n.Conditions {
Walk(v, c)
}
for _, a := range n.Actions {
Walk(v, a)
}
for _, prop := range n.Properties {
Walk(v, prop)
}
case *AlterWorkloadPolicyStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *DropWorkloadPolicyStmt:
// leaf-ish node, no Node children
case *CreateResourceStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *AlterResourceStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *DropResourceStmt:
// leaf-ish node, no Node children
case *CreateSQLBlockRuleStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *AlterSQLBlockRuleStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *DropSQLBlockRuleStmt:
// leaf-ish node, no Node children
}
}
Loading
Loading