ast

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(v Visitor, node Node)

Walk traverses the AST rooted at node using the provided visitor.

Types

type Assignment

type Assignment struct {
	Column *Identifier
	Value  Expr
}

Assignment represents column=expr pairs in UPDATE SET.

type BetweenExpr

type BetweenExpr struct {
	Expr  Expr
	Lower Expr
	Upper Expr
	Not   bool
}

BetweenExpr models BETWEEN operations.

func (*BetweenExpr) Accept

func (b *BetweenExpr) Accept(v Visitor)

type BinaryExpr

type BinaryExpr struct {
	Left     Expr
	Operator string
	Right    Expr
}

BinaryExpr models binary operations like a+b or a AND b.

func (*BinaryExpr) Accept

func (b *BinaryExpr) Accept(v Visitor)

type BooleanLiteral

type BooleanLiteral struct{ Value bool }

Literal kinds.

func (*BooleanLiteral) Accept

func (b *BooleanLiteral) Accept(v Visitor)

type CaseExpr

type CaseExpr struct {
	Operand Expr
	When    []WhenClause
	Else    Expr
}

CaseExpr represents simple CASE constructs.

func (*CaseExpr) Accept

func (c *CaseExpr) Accept(v Visitor)

type CommonTableExpression

type CommonTableExpression struct {
	Name    *Identifier
	Columns []*Identifier
	Select  *SelectStatement
}

CommonTableExpression represents a single named subquery.

type CreateViewStatement

type CreateViewStatement struct {
	OrReplace    bool
	IfNotExists  bool
	Materialized bool
	Name         *Identifier
	Columns      []*Identifier
	Select       *SelectStatement
}

CreateViewStatement models CREATE VIEW statements.

func (*CreateViewStatement) Accept

func (s *CreateViewStatement) Accept(v Visitor)

type DeleteStatement

type DeleteStatement struct {
	Table TableExpr
	Using TableExpr
	Where Expr
}

DeleteStatement models DELETE queries.

func (*DeleteStatement) Accept

func (s *DeleteStatement) Accept(v Visitor)

type DescribeStatement

type DescribeStatement struct {
	Target DescribeTarget
	Name   *Identifier
}

DescribeStatement models DESCRIBE TABLE/VIEW statements.

func (*DescribeStatement) Accept

func (s *DescribeStatement) Accept(v Visitor)

type DescribeTarget

type DescribeTarget string

DescribeTarget enumerates the possible entities a DESCRIBE statement can address.

const (
	DescribeTable DescribeTarget = "TABLE"
	DescribeView  DescribeTarget = "VIEW"
)

type DropViewStatement

type DropViewStatement struct {
	Materialized bool
	IfExists     bool
	Name         *Identifier
}

DropViewStatement models DROP VIEW statements.

func (*DropViewStatement) Accept

func (s *DropViewStatement) Accept(v Visitor)

type ExistsExpr

type ExistsExpr struct {
	Not      bool
	Subquery *SelectStatement
}

ExistsExpr models EXISTS (subquery).

func (*ExistsExpr) Accept

func (e *ExistsExpr) Accept(v Visitor)

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr models SQL expressions.

type FuncCall

type FuncCall struct {
	Name     Identifier
	Distinct bool
	Args     []Expr
	Over     *WindowSpecification
}

FuncCall models function invocations.

func (*FuncCall) Accept

func (f *FuncCall) Accept(v Visitor)

type Identifier

type Identifier struct {
	Parts []string
}

Identifier models possibly qualified identifiers.

func (*Identifier) Accept

func (i *Identifier) Accept(v Visitor)

type InExpr

type InExpr struct {
	Expr     Expr
	Not      bool
	Subquery *SelectStatement
	List     []Expr
}

InExpr models IN and NOT IN.

func (*InExpr) Accept

func (i *InExpr) Accept(v Visitor)

type InsertStatement

type InsertStatement struct {
	Table   *TableName
	Columns []*Identifier
	Rows    [][]Expr
	Select  *SelectStatement
}

InsertStatement models INSERT queries.

func (*InsertStatement) Accept

func (s *InsertStatement) Accept(v Visitor)

type IsNullExpr

type IsNullExpr struct {
	Expr Expr
	Not  bool
}

IsNullExpr models IS [NOT] NULL.

func (*IsNullExpr) Accept

func (i *IsNullExpr) Accept(v Visitor)

type JoinCondition

type JoinCondition struct {
	On Expr
}

JoinCondition captures ON clauses.

type JoinExpr

type JoinExpr struct {
	Left      TableExpr
	Right     TableExpr
	Type      JoinType
	Condition JoinCondition
}

JoinExpr represents a JOIN expression.

func (*JoinExpr) Accept

func (j *JoinExpr) Accept(v Visitor)

type JoinType

type JoinType string

JoinType enumerates supported ANSI join types.

const (
	JoinInner JoinType = "INNER"
	JoinLeft  JoinType = "LEFT"
	JoinRight JoinType = "RIGHT"
	JoinFull  JoinType = "FULL"
	JoinCross JoinType = "CROSS"
)

type LikeExpr

type LikeExpr struct {
	Expr    Expr
	Not     bool
	Pattern Expr
}

LikeExpr models LIKE expressions.

func (*LikeExpr) Accept

func (l *LikeExpr) Accept(v Visitor)

type LimitClause

type LimitClause struct {
	Count  Expr // can be nil for OFFSET only
	Offset Expr
}

LimitClause captures LIMIT/OFFSET values.

type Node

type Node interface {
	Accept(Visitor)
}

Node represents any AST element that can accept a Visitor.

type NullLiteral

type NullLiteral struct{}

Literal kinds.

func (*NullLiteral) Accept

func (n *NullLiteral) Accept(v Visitor)

type NumericLiteral

type NumericLiteral struct{ Value string }

Literal kinds.

func (*NumericLiteral) Accept

func (n *NumericLiteral) Accept(v Visitor)

type OrderDirection

type OrderDirection string

OrderDirection enumerates ORDER BY directions.

const (
	Ascending  OrderDirection = "ASC"
	Descending OrderDirection = "DESC"
)

type OrderItem

type OrderItem struct {
	Expr      Expr
	Direction OrderDirection
}

OrderItem represents ORDER BY terms.

type Placeholder

type Placeholder struct{ Symbol string }

Literal kinds.

func (*Placeholder) Accept

func (p *Placeholder) Accept(v Visitor)

type SelectItem

type SelectItem struct {
	Expr  Expr
	Alias string
}

SelectItem describes an item in the SELECT list.

type SelectStatement

type SelectStatement struct {
	With     *WithClause
	Distinct bool
	Columns  []SelectItem
	From     TableExpr
	Where    Expr
	GroupBy  []Expr
	Having   Expr
	OrderBy  []OrderItem
	Limit    *LimitClause
	SetOps   []SetOperation
}

SelectStatement captures a SELECT query.

func (*SelectStatement) Accept

func (s *SelectStatement) Accept(v Visitor)

Accept satisfies Node for SelectStatement.

type SetOperation

type SetOperation struct {
	Operator SetOperator
	All      bool
	Select   *SelectStatement
}

SetOperation joins the current SELECT with another via UNION/INTERSECT/EXCEPT.

type SetOperator

type SetOperator string

SetOperator describes set combination types.

const (
	SetOpUnion     SetOperator = "UNION"
	SetOpIntersect SetOperator = "INTERSECT"
	SetOpExcept    SetOperator = "EXCEPT"
)

type ShowTablesStatement

type ShowTablesStatement struct{}

ShowTablesStatement models SHOW TABLES commands.

func (*ShowTablesStatement) Accept

func (s *ShowTablesStatement) Accept(v Visitor)

type ShowViewsStatement

type ShowViewsStatement struct{}

ShowViewsStatement models SHOW VIEWS commands.

func (*ShowViewsStatement) Accept

func (s *ShowViewsStatement) Accept(v Visitor)

type StarExpr

type StarExpr struct {
	Table *Identifier
}

StarExpr denotes the wildcard selector.

func (*StarExpr) Accept

func (s *StarExpr) Accept(v Visitor)

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

Statement is the root type for SQL statements.

type StringLiteral

type StringLiteral struct{ Value string }

Literal kinds.

func (*StringLiteral) Accept

func (s *StringLiteral) Accept(v Visitor)

type SubqueryExpr

type SubqueryExpr struct {
	Select *SelectStatement
}

SubqueryExpr allows scalar subqueries.

func (*SubqueryExpr) Accept

func (s *SubqueryExpr) Accept(v Visitor)

type SubqueryTable

type SubqueryTable struct {
	Select *SelectStatement
	Alias  string
}

SubqueryTable wraps a subquery used as table expression.

func (*SubqueryTable) Accept

func (t *SubqueryTable) Accept(v Visitor)

type TableExpr

type TableExpr interface {
	Node
	// contains filtered or unexported methods
}

TableExpr represents selectable table expressions.

type TableName

type TableName struct {
	Name  *Identifier
	Alias string
}

TableName represents a table reference with optional alias.

func (*TableName) Accept

func (t *TableName) Accept(v Visitor)

type UnaryExpr

type UnaryExpr struct {
	Operator string
	Expr     Expr
}

UnaryExpr models prefix operators.

func (*UnaryExpr) Accept

func (u *UnaryExpr) Accept(v Visitor)

type UpdateStatement

type UpdateStatement struct {
	Table       TableExpr
	Assignments []Assignment
	From        TableExpr
	Where       Expr
}

UpdateStatement models UPDATE queries.

func (*UpdateStatement) Accept

func (s *UpdateStatement) Accept(v Visitor)

type Visitor

type Visitor interface {
	Visit(Node) Visitor
}

Visitor is implemented by algorithms that walk the AST.

type WhenClause

type WhenClause struct {
	Condition Expr
	Result    Expr
}

WhenClause holds CASE branches.

type WindowSpecification

type WindowSpecification struct {
	PartitionBy []Expr
	OrderBy     []OrderItem
}

WindowSpecification describes OVER(...) clauses on function calls.

type WithClause

type WithClause struct {
	Recursive bool
	CTEs      []CommonTableExpression
}

WithClause stores common table expressions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL