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
89 changes: 89 additions & 0 deletions doris/ast/catalognodes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package ast

// This file holds DDL AST node types for CATALOG statements (T5.2).
//
// Supported forms:
// CREATE [EXTERNAL] CATALOG [IF NOT EXISTS] name [COMMENT '...'] [PROPERTIES(...)] [WITH RESOURCE name]
// ALTER CATALOG name { RENAME new_name | SET PROPERTIES (...) | MODIFY COMMENT 'text' | PROPERTY (...) }
// DROP CATALOG [IF EXISTS] name
// REFRESH CATALOG name [PROPERTIES(...)]

// CreateCatalogStmt represents:
//
// CREATE [EXTERNAL] CATALOG [IF NOT EXISTS] catalog_name
// [COMMENT 'comment']
// [PROPERTIES ("key"="value", ...)]
// [WITH RESOURCE resource_name]
type CreateCatalogStmt struct {
Name string
External bool
IfNotExists bool
Comment string
Properties []*Property
WithResource string // non-empty when WITH RESOURCE resource_name is present
Loc Loc
}

// Tag implements Node.
func (n *CreateCatalogStmt) Tag() NodeTag { return T_CreateCatalogStmt }

var _ Node = (*CreateCatalogStmt)(nil)

// AlterCatalogAction identifies the kind of action in an ALTER CATALOG statement.
type AlterCatalogAction int

const (
AlterCatalogRename AlterCatalogAction = iota // RENAME new_name
AlterCatalogSetProperties // SET PROPERTIES (...)
AlterCatalogModifyComment // MODIFY COMMENT 'text'
AlterCatalogSetProperty // PROPERTY ("key"="value")
)

// AlterCatalogStmt represents:
//
// ALTER CATALOG name
// { RENAME new_name
// | SET PROPERTIES ("key"="value", ...)
// | MODIFY COMMENT 'text'
// | PROPERTY ("key"="value") }
type AlterCatalogStmt struct {
Name string
Action AlterCatalogAction
NewName string // for RENAME
Properties []*Property // for SET PROPERTIES / PROPERTY
Comment string // for MODIFY COMMENT
Loc Loc
}

// Tag implements Node.
func (n *AlterCatalogStmt) Tag() NodeTag { return T_AlterCatalogStmt }

var _ Node = (*AlterCatalogStmt)(nil)

// DropCatalogStmt represents:
//
// DROP CATALOG [IF EXISTS] catalog_name
type DropCatalogStmt struct {
Name string
IfExists bool
Loc Loc
}

// Tag implements Node.
func (n *DropCatalogStmt) Tag() NodeTag { return T_DropCatalogStmt }

var _ Node = (*DropCatalogStmt)(nil)

// RefreshCatalogStmt represents:
//
// REFRESH CATALOG catalog_name [PROPERTIES(...)]
type RefreshCatalogStmt struct {
Name string
Properties []*Property
Loc Loc
}

// Tag implements Node.
func (n *RefreshCatalogStmt) Tag() NodeTag { return T_RefreshCatalogStmt }

var _ Node = (*RefreshCatalogStmt)(nil)
8 changes: 8 additions & 0 deletions doris/ast/loc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ func NodeLoc(n Node) Loc {
return v.Loc
case *MergeClause:
return v.Loc
case *CreateCatalogStmt:
return v.Loc
case *AlterCatalogStmt:
return v.Loc
case *DropCatalogStmt:
return v.Loc
case *RefreshCatalogStmt:
return v.Loc
default:
return NoLoc()
}
Expand Down
22 changes: 22 additions & 0 deletions doris/ast/nodetags.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ const (

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

// DDL — CATALOG nodes (T5.2).

// T_CreateCatalogStmt is the tag for *CreateCatalogStmt.
T_CreateCatalogStmt

// T_AlterCatalogStmt is the tag for *AlterCatalogStmt.
T_AlterCatalogStmt

// T_DropCatalogStmt is the tag for *DropCatalogStmt.
T_DropCatalogStmt

// T_RefreshCatalogStmt is the tag for *RefreshCatalogStmt.
T_RefreshCatalogStmt
)

// String returns a human-readable representation of the tag.
Expand Down Expand Up @@ -327,6 +341,14 @@ func (t NodeTag) String() string {
return "MergeStmt"
case T_MergeClause:
return "MergeClause"
case T_CreateCatalogStmt:
return "CreateCatalogStmt"
case T_AlterCatalogStmt:
return "AlterCatalogStmt"
case T_DropCatalogStmt:
return "DropCatalogStmt"
case T_RefreshCatalogStmt:
return "RefreshCatalogStmt"
default:
return "Unknown"
}
Expand Down
16 changes: 16 additions & 0 deletions doris/ast/walk_children.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,21 @@ func walkChildren(v Visitor, node Node) {
Walk(v, val)
}
}

// DDL — CATALOG nodes (T5.2).
case *CreateCatalogStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *AlterCatalogStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
case *DropCatalogStmt:
// leaf-ish node, name stored as string
case *RefreshCatalogStmt:
for _, prop := range n.Properties {
Walk(v, prop)
}
}
}
Loading
Loading