ast

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ast provides Abstract Syntax Tree (AST) node definitions for SQL statements. It includes comprehensive support for DDL and DML operations, Common Table Expressions (CTEs), and set operations, with object pooling for performance optimization.

Phase 2 Features (v1.2.0+):

  • WithClause and CommonTableExpr for CTE support
  • SetOperation for UNION, EXCEPT, INTERSECT operations
  • Recursive CTE support with proper AST representation
  • Integration with all statement types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExpressionSlice

func GetExpressionSlice() *[]Expression

GetExpressionSlice gets a slice of Expression from the pool

func GetSpan

func GetSpan(node interface{}) models.Span

GetSpan gets the source location span for an AST node

func Inspect

func Inspect(node Node, f func(Node) bool)

Inspect traverses an AST in depth-first order: It starts by calling f(node); node must not be nil. If f returns true, Inspect invokes f recursively for each of the non-nil children of node, followed by a call of f(nil).

func ParseStructTags

func ParseStructTags(tag string) map[string]string

ParseStructTags parses struct field tags into a map

func PutBinaryExpression

func PutBinaryExpression(expr *BinaryExpression)

PutBinaryExpression returns a BinaryExpression to the pool

func PutDeleteStatement

func PutDeleteStatement(stmt *DeleteStatement)

PutDeleteStatement returns a DeleteStatement to the pool

func PutExpression

func PutExpression(expr Expression)

PutExpression returns any Expression to the appropriate pool

func PutExpressionSlice

func PutExpressionSlice(slice *[]Expression)

PutExpressionSlice returns a slice of Expression to the pool

func PutIdentifier

func PutIdentifier(ident *Identifier)

PutIdentifier returns an Identifier to the pool

func PutInsertStatement

func PutInsertStatement(stmt *InsertStatement)

PutInsertStatement returns an InsertStatement to the pool

func PutLiteralValue

func PutLiteralValue(lit *LiteralValue)

PutLiteralValue returns a LiteralValue to the pool

func PutSelectStatement

func PutSelectStatement(stmt *SelectStatement)

PutSelectStatement returns a SelectStatement to the pool

func PutUpdateExpression

func PutUpdateExpression(expr *UpdateExpression)

PutUpdateExpression returns an UpdateExpression to the pool

func PutUpdateStatement

func PutUpdateStatement(stmt *UpdateStatement)

PutUpdateStatement returns an UpdateStatement to the pool

func ReleaseAST

func ReleaseAST(ast *AST)

ReleaseAST returns an AST to the pool

func SetSpan

func SetSpan(node interface{}, span models.Span)

SetSpan sets the source location span for an AST node

func UnionSpans

func UnionSpans(spans []models.Span) models.Span

UnionSpans returns the union of all spans in the given slice

func Walk

func Walk(v Visitor, node Node) error

Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).

Types

type AST

type AST struct {
	Statements []Statement
}

AST represents the root of the Abstract Syntax Tree

func NewAST

func NewAST() *AST

NewAST creates a new AST from the pool

func (AST) Children

func (a AST) Children() []Node

func (*AST) Span

func (a *AST) Span() models.Span

Span returns the source location span for the AST

func (AST) TokenLiteral

func (a AST) TokenLiteral() string

type AlterColumnOperation

type AlterColumnOperation int

AlterColumnOperation represents operations that can be performed on columns

const (
	AlterColumnSetDefault AlterColumnOperation = iota
	AlterColumnDropDefault
	AlterColumnSetNotNull
	AlterColumnDropNotNull
)

func (*AlterColumnOperation) Children

func (a *AlterColumnOperation) Children() []Node

Make AlterColumnOperation implement Node interface

func (*AlterColumnOperation) TokenLiteral

func (a *AlterColumnOperation) TokenLiteral() string

type AlterConnectorOperation

type AlterConnectorOperation struct {
	Properties map[string]string
	URL        string
	Owner      *AlterConnectorOwner
}

AlterConnectorOperation represents operations that can be performed on a connector

func (AlterConnectorOperation) Children

func (a AlterConnectorOperation) Children() []Node

func (AlterConnectorOperation) TokenLiteral

func (a AlterConnectorOperation) TokenLiteral() string

type AlterConnectorOwner

type AlterConnectorOwner struct {
	IsUser bool
	Name   string
}

AlterConnectorOwner represents the new owner of a connector

type AlterOperation

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

AlterOperation represents the operation to be performed

type AlterPolicyOpType

type AlterPolicyOpType int

AlterPolicyOpType represents the type of policy alteration

const (
	RenamePolicy AlterPolicyOpType = iota
	ModifyPolicy
)

type AlterPolicyOperation

type AlterPolicyOperation struct {
	Type      AlterPolicyOpType
	NewName   string
	To        []string
	Using     Expression
	WithCheck Expression
}

AlterPolicyOperation represents operations that can be performed on a policy

func (AlterPolicyOperation) Children

func (a AlterPolicyOperation) Children() []Node

func (AlterPolicyOperation) TokenLiteral

func (a AlterPolicyOperation) TokenLiteral() string

type AlterRoleOpType

type AlterRoleOpType int

AlterRoleOpType represents the type of role alteration

const (
	RenameRole AlterRoleOpType = iota
	AddMember
	DropMember
	SetConfig
	ResetConfig
	WithOptions
)

type AlterRoleOperation

type AlterRoleOperation struct {
	Type        AlterRoleOpType
	NewName     string
	Options     []RoleOption
	MemberName  string
	ConfigName  string
	ConfigValue Expression
	InDatabase  string
}

AlterRoleOperation represents operations that can be performed on a role

func (AlterRoleOperation) Children

func (a AlterRoleOperation) Children() []Node

func (AlterRoleOperation) TokenLiteral

func (a AlterRoleOperation) TokenLiteral() string

type AlterStatement

type AlterStatement struct {
	Type      AlterType
	Name      string // Name of the object being altered
	Operation AlterOperation
}

AlterStatement represents an ALTER statement

func (AlterStatement) Children

func (a AlterStatement) Children() []Node

func (AlterStatement) TokenLiteral

func (a AlterStatement) TokenLiteral() string

type AlterTableAction

type AlterTableAction struct {
	Type       string // ADD COLUMN, DROP COLUMN, MODIFY COLUMN, etc.
	ColumnName string
	ColumnDef  *ColumnDef
	Constraint *TableConstraint
}

AlterTableAction represents an action in ALTER TABLE

func (AlterTableAction) Children

func (a AlterTableAction) Children() []Node

func (AlterTableAction) TokenLiteral

func (a AlterTableAction) TokenLiteral() string

type AlterTableOpType

type AlterTableOpType int

AlterTableOpType represents the type of table alteration

const (
	AddConstraint AlterTableOpType = iota
	AddColumn
	AddProjection
	AlterColumn
	ChangeColumn
	ClearProjection
	DropColumn
	DropConstraint
	DropPartition
	DropProjection
	MaterializeProjection
	ModifyColumn
	RenameColumn
	RenameConstraint
	RenamePartitions
	RenameTable
)

type AlterTableOperation

type AlterTableOperation struct {
	Type             AlterTableOpType
	ColumnKeyword    bool                  // Used for AddColumn
	IfNotExists      bool                  // Used for AddColumn, AddPartition
	IfExists         bool                  // Used for DropColumn, DropConstraint, DropPartition
	ColumnDef        *ColumnDef            // Used for AddColumn
	ColumnPosition   *ColumnPosition       // Used for AddColumn, ChangeColumn, ModifyColumn
	Constraint       *TableConstraint      // Used for AddConstraint
	ProjectionName   *Ident                // Used for AddProjection, DropProjection
	ProjectionSelect *Select               // Used for AddProjection
	PartitionName    *Ident                // Used for MaterializeProjection, ClearProjection
	OldColumnName    *Ident                // Used for RenameColumn
	NewColumnName    *Ident                // Used for RenameColumn
	TableName        ObjectName            // Used for RenameTable
	NewTableName     ObjectName            // Used for RenameTable
	OldPartitions    []*Expression         // Used for RenamePartitions
	NewPartitions    []*Expression         // Used for RenamePartitions
	Partitions       []*Partition          // Used for AddPartitions
	DropBehavior     DropBehavior          // Used for DropColumn, DropConstraint
	ConstraintName   *Ident                // Used for DropConstraint
	OldName          *Ident                // Used for RenameConstraint
	NewName          *Ident                // Used for RenameConstraint
	ColumnName       *Ident                // Used for AlterColumn
	AlterColumnOp    *AlterColumnOperation // Used for AlterColumn
	CascadeDrops     bool                  // Used for DropColumn, DropConstraint
}

AlterTableOperation represents operations that can be performed on a table

func (AlterTableOperation) Children

func (a AlterTableOperation) Children() []Node

func (AlterTableOperation) TokenLiteral

func (a AlterTableOperation) TokenLiteral() string

type AlterTableStatement

type AlterTableStatement struct {
	Table   string
	Actions []AlterTableAction
}

AlterTableStatement represents an ALTER TABLE statement

func (AlterTableStatement) Children

func (a AlterTableStatement) Children() []Node

func (AlterTableStatement) TokenLiteral

func (a AlterTableStatement) TokenLiteral() string

type AlterType

type AlterType int

AlterType represents the type of object being altered

const (
	AlterTypeTable AlterType = iota
	AlterTypeRole
	AlterTypePolicy
	AlterTypeConnector
)

type ArrayBracketType

type ArrayBracketType int
const (
	NoBrackets ArrayBracketType = iota
	AngleBrackets
	SquareBrackets
	Parentheses
)

type ArrayElemTypeDef

type ArrayElemTypeDef struct {
	Type     *DataType
	Size     *uint64
	Brackets ArrayBracketType
}

ArrayElemTypeDef represents array element type definition

func (*ArrayElemTypeDef) String

func (a *ArrayElemTypeDef) String() string

type ArrayType

type ArrayType struct {
	ElementType *ArrayElemTypeDef
}

Basic data types

func (*ArrayType) String

func (t *ArrayType) String() string

type AttachedToken

type AttachedToken struct {
	Token TokenWithSpan
}

AttachedToken is a wrapper over TokenWithSpan that ignores the token and source location in comparisons and hashing.

This type is used when the token and location is not relevant for semantics, but is still needed for accurate source location tracking.

Note: ALL AttachedTokens are equal.

Examples:

Same token, different location are equal:

// commas @ line 1, column 10
tok1 := NewTokenWithSpan(
    Token{Type: Comma},
    Span{Start: Location{Line: 1, Column: 10}, End: Location{Line: 1, Column: 11}},
)
// commas @ line 2, column 20
tok2 := NewTokenWithSpan(
    Token{Type: Comma},
    Span{Start: Location{Line: 2, Column: 20}, End: Location{Line: 2, Column: 21}},
)

// token with locations are *not* equal
fmt.Println(tok1 != tok2) // true
// attached tokens are equal
fmt.Println(AttachedToken{tok1} == AttachedToken{tok2}) // true

Different token, different location are equal:

// commas @ line 1, column 10
tok1 := NewTokenWithSpan(
    Token{Type: Comma},
    Span{Start: Location{Line: 1, Column: 10}, End: Location{Line: 1, Column: 11}},
)
// period @ line 2, column 20
tok2 := NewTokenWithSpan(
    Token{Type: Period},
    Span{Start: Location{Line: 2, Column: 20}, End: Location{Line: 2, Column: 21}},
)

// token with locations are *not* equal
fmt.Println(tok1 != tok2) // true
// attached tokens are equal
fmt.Println(AttachedToken{tok1} == AttachedToken{tok2}) // true

func NewAttachedToken

func NewAttachedToken(token TokenWithSpan) AttachedToken

NewAttachedToken creates a new AttachedToken from a TokenWithSpan

func WrapToken

func WrapToken(token TokenWithSpan) AttachedToken

WrapToken wraps a TokenWithSpan in an AttachedToken

func (AttachedToken) Compare

func (a AttachedToken) Compare(other AttachedToken) int

Compare implements comparison Note: ALL AttachedTokens are equal

func (AttachedToken) Empty

func (a AttachedToken) Empty() AttachedToken

Empty returns a new Empty AttachedToken

func (AttachedToken) Equal

func (a AttachedToken) Equal(other AttachedToken) bool

Equal implements equality comparison Note: ALL AttachedTokens are equal

func (AttachedToken) GoString

func (a AttachedToken) GoString() string

GoString implements fmt.GoStringer

func (AttachedToken) Hash

func (a AttachedToken) Hash(h hash.Hash)

Hash implements hashing Note: ALL AttachedTokens have the same hash

func (AttachedToken) String

func (a AttachedToken) String() string

String implements fmt.Stringer

func (AttachedToken) UnwrapToken

func (a AttachedToken) UnwrapToken() TokenWithSpan

UnwrapToken returns the underlying TokenWithSpan

type BetweenExpression

type BetweenExpression struct {
	Expr  Expression
	Lower Expression
	Upper Expression
	Not   bool
}

BetweenExpression represents expr BETWEEN lower AND upper

func (BetweenExpression) Children

func (b BetweenExpression) Children() []Node

func (BetweenExpression) TokenLiteral

func (b BetweenExpression) TokenLiteral() string

type BinaryExpression

type BinaryExpression struct {
	Left     Expression
	Operator string
	Right    Expression
	Not      bool                  // For NOT (expr)
	CustomOp *CustomBinaryOperator // For PostgreSQL custom operators
}

BinaryExpression represents operations like WHERE column = value

func GetBinaryExpression

func GetBinaryExpression() *BinaryExpression

GetBinaryExpression gets a BinaryExpression from the pool

func (BinaryExpression) Children

func (b BinaryExpression) Children() []Node

func (*BinaryExpression) Span

func (e *BinaryExpression) Span() models.Span

Span returns the source location span for expressions

func (*BinaryExpression) TokenLiteral

func (b *BinaryExpression) TokenLiteral() string

type BinaryLength

type BinaryLength struct {
	Length uint64
	IsMax  bool
}

BinaryLength represents binary length information

func (*BinaryLength) String

func (b *BinaryLength) String() string

type BinaryOperator

type BinaryOperator int

BinaryOperator represents binary operators in SQL expressions

const (
	// BinaryOpNone represents no operator (zero value)
	BinaryOpNone BinaryOperator = iota
	// BinaryPlus represents addition operator, e.g. a + b
	BinaryPlus
	// BinaryMinus represents subtraction operator, e.g. a - b
	BinaryMinus
	// Multiply represents multiplication operator, e.g. a * b
	Multiply
	// Divide represents division operator, e.g. a / b
	Divide
	// Modulo represents modulo operator, e.g. a % b
	Modulo
	// StringConcat represents string/array concatenation operator, e.g. a || b
	StringConcat
	// Gt represents greater than operator, e.g. a > b
	Gt
	// Lt represents less than operator, e.g. a < b
	Lt
	// GtEq represents greater than or equal operator, e.g. a >= b
	GtEq
	// LtEq represents less than or equal operator, e.g. a <= b
	LtEq
	// Spaceship represents spaceship operator, e.g. a <=> b
	Spaceship
	// Eq represents equality operator, e.g. a = b
	Eq
	// NotEq represents inequality operator, e.g. a <> b
	NotEq
	// And represents logical AND operator, e.g. a AND b
	And
	// Or represents logical OR operator, e.g. a OR b
	Or
	// Xor represents logical XOR operator, e.g. a XOR b
	Xor
	// BitwiseOr represents bitwise OR operator, e.g. a | b
	BitwiseOr
	// BitwiseAnd represents bitwise AND operator, e.g. a & b
	BitwiseAnd
	// BitwiseXor represents bitwise XOR operator, e.g. a ^ b
	BitwiseXor
	// DuckIntegerDivide represents DuckDB integer division operator, e.g. a // b
	DuckIntegerDivide
	// MyIntegerDivide represents MySQL DIV integer division operator
	MyIntegerDivide
	// PGBitwiseXor represents PostgreSQL bitwise XOR operator, e.g. a # b
	PGBitwiseXor
	// PGBitwiseShiftLeft represents PostgreSQL bitwise shift left operator, e.g. a << b
	PGBitwiseShiftLeft
	// PGBitwiseShiftRight represents PostgreSQL bitwise shift right operator, e.g. a >> b
	PGBitwiseShiftRight
	// PGExp represents PostgreSQL exponentiation operator, e.g. a ^ b
	PGExp
	// PGOverlap represents PostgreSQL overlap operator, e.g. a && b
	PGOverlap
	// PGRegexMatch represents PostgreSQL case-sensitive regex match operator, e.g. a ~ b
	PGRegexMatch
	// PGRegexIMatch represents PostgreSQL case-insensitive regex match operator, e.g. a ~* b
	PGRegexIMatch
	// PGRegexNotMatch represents PostgreSQL case-sensitive regex non-match operator, e.g. a !~ b
	PGRegexNotMatch
	// PGRegexNotIMatch represents PostgreSQL case-insensitive regex non-match operator, e.g. a !~* b
	PGRegexNotIMatch
	// PGLikeMatch represents PostgreSQL case-sensitive LIKE match operator, e.g. a ~~ b
	PGLikeMatch
	// PGILikeMatch represents PostgreSQL case-insensitive LIKE match operator, e.g. a ~~* b
	PGILikeMatch
	// PGNotLikeMatch represents PostgreSQL case-sensitive NOT LIKE match operator, e.g. a !~~ b
	PGNotLikeMatch
	// PGNotILikeMatch represents PostgreSQL case-insensitive NOT LIKE match operator, e.g. a !~~* b
	PGNotILikeMatch
	// PGStartsWith represents PostgreSQL starts-with operator, e.g. a ^@ b
	PGStartsWith
	// Arrow represents JSON field/array element access operator, e.g. a -> b
	Arrow
	// LongArrow represents JSON field/array element access with text conversion operator, e.g. a ->> b
	LongArrow
	// HashArrow represents JSON path access operator, e.g. a #> b
	HashArrow
	// HashLongArrow represents JSON path access with text conversion operator, e.g. a #>> b
	HashLongArrow
	// AtAt represents PostgreSQL text/JSON search operator, e.g. a @@ b
	AtAt
	// AtArrow represents PostgreSQL contains operator, e.g. a @> b
	AtArrow
	// ArrowAt represents PostgreSQL contained by operator, e.g. a <@ b
	ArrowAt
	// HashMinus represents PostgreSQL JSON delete operator, e.g. a #- b
	HashMinus
	// AtQuestion represents PostgreSQL JSON path exists operator, e.g. a @? b
	AtQuestion
	// Question represents PostgreSQL JSON key exists operator, e.g. a ? b
	Question
	// QuestionAnd represents PostgreSQL JSON all keys exist operator, e.g. a ?& b
	QuestionAnd
	// QuestionPipe represents PostgreSQL JSON any key exists operator, e.g. a ?| b
	QuestionPipe
	// Overlaps represents SQL OVERLAPS operator for datetime periods
	Overlaps
)

func (BinaryOperator) String

func (op BinaryOperator) String() string

String returns the string representation of the binary operator

type BinaryType

type BinaryType struct {
	Length *BinaryLength
}

Basic data types

func (*BinaryType) String

func (t *BinaryType) String() string

type BooleanType

type BooleanType struct{}

Basic data types

func (*BooleanType) String

func (*BooleanType) String() string

type CaseExpression

type CaseExpression struct {
	Value       Expression // Optional CASE value
	WhenClauses []WhenClause
	ElseClause  Expression
}

CaseExpression represents a CASE expression

func (CaseExpression) Children

func (c CaseExpression) Children() []Node

func (CaseExpression) TokenLiteral

func (c CaseExpression) TokenLiteral() string

type CastExpression

type CastExpression struct {
	Expr Expression
	Type string
}

CastExpression represents CAST(expr AS type)

func (CastExpression) Children

func (c CastExpression) Children() []Node

func (*CastExpression) Span

func (e *CastExpression) Span() models.Span

func (CastExpression) TokenLiteral

func (c CastExpression) TokenLiteral() string

type CharLengthUnits

type CharLengthUnits int

CharLengthUnits represents possible units for characters

const (
	Characters CharLengthUnits = iota
	Octets
)

func (CharLengthUnits) String

func (u CharLengthUnits) String() string

type CharacterLength

type CharacterLength struct {
	Length uint64
	Unit   *CharLengthUnits
}

CharacterLength represents character length information

func (*CharacterLength) String

func (c *CharacterLength) String() string

type CharacterType

type CharacterType struct {
	Length *CharacterLength
}

Basic data types

func (*CharacterType) String

func (t *CharacterType) String() string

type ClusteredBy

type ClusteredBy struct {
	Columns []Node
	Buckets int
}

ClusteredBy represents CLUSTERED BY clause

func (*ClusteredBy) Children

func (c *ClusteredBy) Children() []Node

func (*ClusteredBy) TokenLiteral

func (c *ClusteredBy) TokenLiteral() string

type ColumnConstraint

type ColumnConstraint struct {
	Type          string // NOT NULL, UNIQUE, PRIMARY KEY, etc.
	Default       Expression
	References    *ReferenceDefinition
	Check         Expression
	AutoIncrement bool
}

ColumnConstraint represents a column constraint

func (ColumnConstraint) Children

func (c ColumnConstraint) Children() []Node

func (*ColumnConstraint) String

func (c *ColumnConstraint) String() string

String returns a string representation of a ColumnConstraint

func (ColumnConstraint) TokenLiteral

func (c ColumnConstraint) TokenLiteral() string

type ColumnDef

type ColumnDef struct {
	Name        string
	Type        string
	Constraints []ColumnConstraint
}

ColumnDef represents a column definition in CREATE TABLE

func (ColumnDef) Children

func (c ColumnDef) Children() []Node

func (*ColumnDef) String

func (c *ColumnDef) String() string

String returns a string representation of a ColumnDef

func (ColumnDef) TokenLiteral

func (c ColumnDef) TokenLiteral() string

type ColumnPosition

type ColumnPosition struct {
	First    bool
	After    *Ident
	Position int
}

ColumnPosition represents the position of a column in a table

type CommentDef

type CommentDef struct {
	Text string
}

CommentDef represents a comment on a database object

func (*CommentDef) Children

func (c *CommentDef) Children() []Node

func (*CommentDef) TokenLiteral

func (c *CommentDef) TokenLiteral() string

type CommonTableExpr

type CommonTableExpr struct {
	Name         string
	Columns      []string
	Statement    Statement
	Materialized *bool // TODO: Add MATERIALIZED/NOT MATERIALIZED parsing support
}

CommonTableExpr represents a single Common Table Expression in a WITH clause. It supports optional column specifications and any statement type as the CTE query. Phase 2 Complete: Full parser support with column specifications.

func (CommonTableExpr) Children

func (c CommonTableExpr) Children() []Node

func (CommonTableExpr) TokenLiteral

func (c CommonTableExpr) TokenLiteral() string

type CreateIndexStatement

type CreateIndexStatement struct {
	Unique      bool
	IfNotExists bool
	Name        string
	Table       string
	Columns     []IndexColumn
	Using       string
	Where       Expression
}

CreateIndexStatement represents a CREATE INDEX statement

func (CreateIndexStatement) Children

func (c CreateIndexStatement) Children() []Node

func (CreateIndexStatement) TokenLiteral

func (c CreateIndexStatement) TokenLiteral() string

type CreateTable

type CreateTable struct {
	Name                  ObjectName
	Columns               []ColumnDef
	Constraints           []TableConstraint
	Options               *[]SqlOption
	IfNotExists           bool
	Temporary             bool
	External              bool
	Stored                bool
	Transient             bool
	OrReplace             bool
	Global                *bool
	Volatile              bool
	Iceberg               bool
	HiveDistribution      HiveDistributionStyle
	HiveFormats           *HiveFormat
	TableProperties       []SqlOption
	WithOptions           []SqlOption
	FileFormat            *FileFormat
	Location              *string
	Query                 *Query
	WithoutRowID          bool
	Like                  *ObjectName
	Clone                 *ObjectName
	Engine                *TableEngine
	Comment               *CommentDef
	AutoIncrementOffset   *uint32
	DefaultCharset        *string
	Collation             *string
	OnCommit              *OnCommit
	OnCluster             *Ident
	PrimaryKey            *Expr
	OrderBy               *OneOrManyWithParens[Expr]
	PartitionBy           *Expr
	ClusterBy             *WrappedCollection[[]Ident]
	ClusteredBy           *ClusteredBy
	Strict                bool
	CopyGrants            bool
	EnableSchemaEvolution *bool
	ChangeTracking        *bool
	DataRetentionDays     *uint64
	MaxDataExtensionDays  *uint64
	DefaultDDLCollation   *string
	AggregationPolicy     *ObjectName
	RowAccessPolicy       *RowAccessPolicy
	Tags                  *[]Tag
	BaseLocation          *string
	ExternalVolume        *string
	Catalog               *string
	CatalogSync           *string
	SerializationPolicy   *StorageSerializationPolicy
}

CreateTable represents a CREATE TABLE statement

func (*CreateTable) Children

func (c *CreateTable) Children() []Node

func (*CreateTable) TokenLiteral

func (c *CreateTable) TokenLiteral() string

type CreateTableBuilder

type CreateTableBuilder struct {
	OrReplace             bool
	Temporary             bool
	External              bool
	Global                *bool
	IfNotExists           bool
	Transient             bool
	Volatile              bool
	Iceberg               bool
	Name                  ObjectName
	Columns               []ColumnDef
	Constraints           []TableConstraint
	HiveDistribution      HiveDistributionStyle
	HiveFormats           *HiveFormat
	TableProperties       []SqlOption
	WithOptions           []SqlOption
	FileFormat            *FileFormat
	Location              *string
	Query                 *Query
	WithoutRowID          bool
	Like                  *ObjectName
	Clone                 *ObjectName
	Engine                *TableEngine
	Comment               *CommentDef
	AutoIncrementOffset   *uint32
	DefaultCharset        *string
	Collation             *string
	OnCommit              *OnCommit
	OnCluster             *Ident
	PrimaryKey            *Expr
	OrderBy               *OneOrManyWithParens[Expr]
	PartitionBy           *Expr
	ClusterBy             *WrappedCollection[[]Ident]
	ClusteredBy           *ClusteredBy
	Options               *[]SqlOption
	Strict                bool
	CopyGrants            bool
	EnableSchemaEvolution *bool
	ChangeTracking        *bool
	DataRetentionDays     *uint64
	MaxDataExtensionDays  *uint64
	DefaultDDLCollation   *string
	AggregationPolicy     *ObjectName
	RowAccessPolicy       *RowAccessPolicy
	Tags                  *[]Tag
	BaseLocation          *string
	ExternalVolume        *string
	Catalog               *string
	CatalogSync           *string
	SerializationPolicy   *StorageSerializationPolicy
}

CreateTableBuilder helps in building and accessing a create table statement with more ease. Example:

builder := NewCreateTableBuilder(ObjectName{Idents: []Ident{{Value: "table_name"}}}).
    SetIfNotExists(true).
    SetColumns([]ColumnDef{{
        Name:     Ident{Value: "c1"},
        DataType: &DataType{Variant: &Int32Type{}},
    }})

func FromStatement

func FromStatement(stmt *StatementImpl) (*CreateTableBuilder, error)

FromStatement attempts to create a CreateTableBuilder from a Statement

func NewCreateTableBuilder

func NewCreateTableBuilder(name ObjectName) *CreateTableBuilder

NewCreateTableBuilder creates a new CreateTableBuilder with default values

func (*CreateTableBuilder) Build

func (b *CreateTableBuilder) Build() *StatementImpl

Build converts the builder into a CreateTable statement

func (*CreateTableBuilder) SetAggregationPolicy

func (b *CreateTableBuilder) SetAggregationPolicy(v *ObjectName) *CreateTableBuilder

func (*CreateTableBuilder) SetAutoIncrementOffset

func (b *CreateTableBuilder) SetAutoIncrementOffset(v *uint32) *CreateTableBuilder

func (*CreateTableBuilder) SetBaseLocation

func (b *CreateTableBuilder) SetBaseLocation(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetCatalog

func (b *CreateTableBuilder) SetCatalog(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetCatalogSync

func (b *CreateTableBuilder) SetCatalogSync(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetChangeTracking

func (b *CreateTableBuilder) SetChangeTracking(v *bool) *CreateTableBuilder

func (*CreateTableBuilder) SetClone

func (*CreateTableBuilder) SetClusterBy

func (*CreateTableBuilder) SetClusteredBy

func (b *CreateTableBuilder) SetClusteredBy(v *ClusteredBy) *CreateTableBuilder

func (*CreateTableBuilder) SetCollation

func (b *CreateTableBuilder) SetCollation(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetColumns

func (b *CreateTableBuilder) SetColumns(v []ColumnDef) *CreateTableBuilder

func (*CreateTableBuilder) SetComment

func (*CreateTableBuilder) SetConstraints

func (b *CreateTableBuilder) SetConstraints(v []TableConstraint) *CreateTableBuilder

func (*CreateTableBuilder) SetCopyGrants

func (b *CreateTableBuilder) SetCopyGrants(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetDataRetentionDays

func (b *CreateTableBuilder) SetDataRetentionDays(v *uint64) *CreateTableBuilder

func (*CreateTableBuilder) SetDefaultCharset

func (b *CreateTableBuilder) SetDefaultCharset(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetDefaultDDLCollation

func (b *CreateTableBuilder) SetDefaultDDLCollation(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetEnableSchemaEvolution

func (b *CreateTableBuilder) SetEnableSchemaEvolution(v *bool) *CreateTableBuilder

func (*CreateTableBuilder) SetEngine

func (*CreateTableBuilder) SetExternal

func (b *CreateTableBuilder) SetExternal(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetExternalVolume

func (b *CreateTableBuilder) SetExternalVolume(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetFileFormat

func (b *CreateTableBuilder) SetFileFormat(v *FileFormat) *CreateTableBuilder

func (*CreateTableBuilder) SetGlobal

func (b *CreateTableBuilder) SetGlobal(v *bool) *CreateTableBuilder

func (*CreateTableBuilder) SetHiveDistribution

func (b *CreateTableBuilder) SetHiveDistribution(v HiveDistributionStyle) *CreateTableBuilder

func (*CreateTableBuilder) SetHiveFormats

func (b *CreateTableBuilder) SetHiveFormats(v *HiveFormat) *CreateTableBuilder

func (*CreateTableBuilder) SetIceberg

func (b *CreateTableBuilder) SetIceberg(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetIfNotExists

func (b *CreateTableBuilder) SetIfNotExists(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetLike

func (*CreateTableBuilder) SetLocation

func (b *CreateTableBuilder) SetLocation(v *string) *CreateTableBuilder

func (*CreateTableBuilder) SetMaxDataExtensionDays

func (b *CreateTableBuilder) SetMaxDataExtensionDays(v *uint64) *CreateTableBuilder

func (*CreateTableBuilder) SetOnCluster

func (b *CreateTableBuilder) SetOnCluster(v *Ident) *CreateTableBuilder

func (*CreateTableBuilder) SetOnCommit

func (b *CreateTableBuilder) SetOnCommit(v *OnCommit) *CreateTableBuilder

func (*CreateTableBuilder) SetOptions

func (b *CreateTableBuilder) SetOptions(v *[]SqlOption) *CreateTableBuilder

func (*CreateTableBuilder) SetOrReplace

func (b *CreateTableBuilder) SetOrReplace(v bool) *CreateTableBuilder

Fluent builder methods

func (*CreateTableBuilder) SetOrderBy

func (*CreateTableBuilder) SetPartitionBy

func (b *CreateTableBuilder) SetPartitionBy(v *Expr) *CreateTableBuilder

func (*CreateTableBuilder) SetPrimaryKey

func (b *CreateTableBuilder) SetPrimaryKey(v *Expr) *CreateTableBuilder

func (*CreateTableBuilder) SetQuery

func (b *CreateTableBuilder) SetQuery(v *Query) *CreateTableBuilder

func (*CreateTableBuilder) SetRowAccessPolicy

func (b *CreateTableBuilder) SetRowAccessPolicy(v *RowAccessPolicy) *CreateTableBuilder

func (*CreateTableBuilder) SetSerializationPolicy

func (b *CreateTableBuilder) SetSerializationPolicy(v *StorageSerializationPolicy) *CreateTableBuilder

func (*CreateTableBuilder) SetStrict

func (b *CreateTableBuilder) SetStrict(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetTableProperties

func (b *CreateTableBuilder) SetTableProperties(v []SqlOption) *CreateTableBuilder

func (*CreateTableBuilder) SetTags

func (b *CreateTableBuilder) SetTags(v *[]Tag) *CreateTableBuilder

func (*CreateTableBuilder) SetTemporary

func (b *CreateTableBuilder) SetTemporary(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetTransient

func (b *CreateTableBuilder) SetTransient(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetVolatile

func (b *CreateTableBuilder) SetVolatile(v bool) *CreateTableBuilder

func (*CreateTableBuilder) SetWithOptions

func (b *CreateTableBuilder) SetWithOptions(v []SqlOption) *CreateTableBuilder

func (*CreateTableBuilder) SetWithoutRowID

func (b *CreateTableBuilder) SetWithoutRowID(v bool) *CreateTableBuilder

type CreateTableStatement

type CreateTableStatement struct {
	IfNotExists bool
	Temporary   bool
	Name        string
	Columns     []ColumnDef
	Constraints []TableConstraint
	Inherits    []string
	PartitionBy *PartitionBy
	Options     []TableOption
}

CreateTableStatement represents a CREATE TABLE statement

func (CreateTableStatement) Children

func (c CreateTableStatement) Children() []Node

func (CreateTableStatement) TokenLiteral

func (c CreateTableStatement) TokenLiteral() string

type CustomBinaryOperator

type CustomBinaryOperator struct {
	Parts []string
}

CustomBinaryOperator represents a custom binary operator (PostgreSQL-specific)

func (*CustomBinaryOperator) String

func (op *CustomBinaryOperator) String() string

String returns the string representation of the custom binary operator

type CustomType

type CustomType struct {
	Name      ObjectName
	Modifiers []string
}

Basic data types

func (*CustomType) String

func (t *CustomType) String() string

type DataLoadingOption

type DataLoadingOption struct {
	OptionName string
	OptionType DataLoadingOptionType
	Value      string
}

DataLoadingOption represents a single data loading option

func NewBooleanOption

func NewBooleanOption(name string, value bool) DataLoadingOption

NewBooleanOption creates a new boolean-type DataLoadingOption

func NewEnumOption

func NewEnumOption(name, value string) DataLoadingOption

NewEnumOption creates a new enum-type DataLoadingOption

func NewNumberOption

func NewNumberOption(name string, value interface{}) DataLoadingOption

NewNumberOption creates a new number-type DataLoadingOption

func NewStringOption

func NewStringOption(name, value string) DataLoadingOption

NewStringOption creates a new string-type DataLoadingOption

func (*DataLoadingOption) String

func (d *DataLoadingOption) String() string

String implements the Stringer interface for DataLoadingOption

type DataLoadingOptionType

type DataLoadingOptionType int

DataLoadingOptionType represents the type of a data loading option

const (
	DataLoadingOptionTypeString DataLoadingOptionType = iota
	DataLoadingOptionTypeBoolean
	DataLoadingOptionTypeEnum
	DataLoadingOptionTypeNumber
)

type DataLoadingOptions

type DataLoadingOptions struct {
	Options []DataLoadingOption
}

DataLoadingOptions represents a collection of data loading options

func (*DataLoadingOptions) String

func (d *DataLoadingOptions) String() string

String implements the Stringer interface for DataLoadingOptions

type DataType

type DataType struct {
	Type DataTypeVariant
}

DataType represents SQL data types

type DataTypeVariant

type DataTypeVariant interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

DataTypeVariant represents the different variants of SQL data types

type DateTimeField

type DateTimeField int

DateTimeField represents date/time fields that can be extracted or used in operations

const (
	Year DateTimeField = iota
	Years
	Month
	Months
	Week
	Weeks
	Day
	DayOfWeek
	DayOfYear
	Days
	Date
	Datetime
	Hour
	Hours
	Minute
	Minutes
	Second
	Seconds
	Century
	Decade
	Dow
	Doy
	Epoch
	Isodow
	IsoWeek
	Isoyear
	Julian
	Microsecond
	Microseconds
	Millenium
	Millennium
	Millisecond
	Milliseconds
	Nanosecond
	Nanoseconds
	Quarter
	Time
	Timezone
	TimezoneAbbr
	TimezoneHour
	TimezoneMinute
	TimezoneRegion
	NoDateTime
	CustomDateTime
)

func (DateTimeField) String

func (d DateTimeField) String() string

type DateType

type DateType struct{}

Basic data types

func (*DateType) String

func (*DateType) String() string

type Delete

type Delete struct {
	Table           TableReference
	Where           Expression
	ReturningClause []Expression
}

Delete represents a DELETE statement

func (Delete) Children

func (d Delete) Children() []Node

func (Delete) TokenLiteral

func (d Delete) TokenLiteral() string

type DeleteStatement

type DeleteStatement struct {
	With      *WithClause
	TableName string
	Alias     string
	Using     []TableReference
	Where     Expression
	Returning []Expression
}

DeleteStatement represents a DELETE SQL statement

func GetDeleteStatement

func GetDeleteStatement() *DeleteStatement

GetDeleteStatement gets a DeleteStatement from the pool

func (DeleteStatement) Children

func (d DeleteStatement) Children() []Node

func (*DeleteStatement) Span

func (d *DeleteStatement) Span() models.Span

Span returns the source location span for the DeleteStatement

func (DeleteStatement) TokenLiteral

func (d DeleteStatement) TokenLiteral() string

type DollarQuotedString

type DollarQuotedString struct {
	Value string
	Tag   string
}

DollarQuotedString represents a dollar-quoted string with an optional tag

type DropBehavior

type DropBehavior int

DropBehavior specifies the behavior when dropping objects

const (
	DropCascade DropBehavior = iota
	DropRestrict
)

type EnumMember

type EnumMember struct {
	Name  string
	Value Expression
}

EnumMember represents a member of an ENUM type

func (*EnumMember) String

func (e *EnumMember) String() string

type EnumType

type EnumType struct {
	Values []EnumMember
	Bits   *uint8
}

Basic data types

func (*EnumType) String

func (t *EnumType) String() string

type ExactNumberInfo

type ExactNumberInfo struct {
	Precision *uint64
	Scale     *uint64
}

ExactNumberInfo represents precision and scale information

func (*ExactNumberInfo) String

func (e *ExactNumberInfo) String() string

type ExistsExpression

type ExistsExpression struct {
	Subquery Statement
}

ExistsExpression represents EXISTS (subquery)

func (ExistsExpression) Children

func (e ExistsExpression) Children() []Node

func (ExistsExpression) TokenLiteral

func (e ExistsExpression) TokenLiteral() string

type Expr

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

Expr represents a SQL expression

type Expression

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

Expression represents a SQL expression

type ExtractExpression

type ExtractExpression struct {
	Field  string
	Source Expression
}

ExtractExpression represents EXTRACT(field FROM source)

func (ExtractExpression) Children

func (e ExtractExpression) Children() []Node

func (ExtractExpression) TokenLiteral

func (e ExtractExpression) TokenLiteral() string

type FileFormat

type FileFormat int

FileFormat represents file format specifications

const (
	FileFormatNone FileFormat = iota
	FileFormatCSV
	FileFormatJSON
	FileFormatParquet
)

type FileStagingCommand

type FileStagingCommand struct {
	Stage   ObjectName
	Pattern *string
}

FileStagingCommand represents a file staging command

func (*FileStagingCommand) String

func (f *FileStagingCommand) String() string

String implements the Stringer interface for FileStagingCommand

type FloatType

type FloatType struct {
	Length *uint64
}

Basic data types

func (*FloatType) String

func (t *FloatType) String() string

type FunctionCall

type FunctionCall struct {
	Name      string
	Arguments []Expression // Renamed from Args for consistency
	Over      *WindowSpec  // For window functions
	Distinct  bool
	Filter    Expression // WHERE clause for aggregate functions
}

FunctionCall represents a function call expression

func (FunctionCall) Children

func (f FunctionCall) Children() []Node

func (*FunctionCall) Span

func (e *FunctionCall) Span() models.Span

func (FunctionCall) TokenLiteral

func (f FunctionCall) TokenLiteral() string

type FunctionDesc

type FunctionDesc struct {
	Name      ObjectName
	Schema    string // Optional schema qualifier
	Arguments []string
}

FunctionDesc represents a function descriptor used in SQL statements

func (FunctionDesc) Children

func (f FunctionDesc) Children() []Node

Implement Node interface

func (FunctionDesc) String

func (f FunctionDesc) String() string

func (FunctionDesc) TokenLiteral

func (f FunctionDesc) TokenLiteral() string

type HiveDistributionStyle

type HiveDistributionStyle int

HiveDistributionStyle represents Hive-specific distribution styles

const (
	HiveDistributionNone HiveDistributionStyle = iota
	HiveDistributionHash
	HiveDistributionRandom
)

type HiveFormat

type HiveFormat int

HiveFormat represents Hive-specific storage formats

const (
	HiveFormatNone HiveFormat = iota
	HiveFormatORC
	HiveFormatParquet
	HiveFormatAvro
)

type Ident

type Ident struct {
	Name string
}

Ident represents an identifier in SQL (table name, column name, etc.)

func (*Ident) Children

func (i *Ident) Children() []Node

func (*Ident) String

func (i *Ident) String() string

func (*Ident) TokenLiteral

func (i *Ident) TokenLiteral() string

type Identifier

type Identifier struct {
	Name  string
	Table string // Optional table qualifier
}

Identifier represents a column or table name

func GetIdentifier

func GetIdentifier() *Identifier

GetIdentifier gets an Identifier from the pool

func (Identifier) Children

func (i Identifier) Children() []Node

func (Identifier) TokenLiteral

func (i Identifier) TokenLiteral() string

type InExpression

type InExpression struct {
	Expr Expression
	List []Expression
	Not  bool
}

InExpression represents expr IN (values)

func (InExpression) Children

func (i InExpression) Children() []Node

func (InExpression) TokenLiteral

func (i InExpression) TokenLiteral() string

type IndexColumn

type IndexColumn struct {
	Column    string
	Collate   string
	Direction string // ASC, DESC
	NullsLast bool
}

IndexColumn represents a column in an index definition

func (IndexColumn) Children

func (i IndexColumn) Children() []Node

func (IndexColumn) TokenLiteral

func (i IndexColumn) TokenLiteral() string

type IndexOption

type IndexOption struct {
	Type    IndexOptionType
	Using   *IndexType // Used for Using
	Comment string     // Used for Comment
}

IndexOption represents MySQL index options

func (*IndexOption) String

func (opt *IndexOption) String() string

type IndexOptionType

type IndexOptionType int
const (
	UsingIndex IndexOptionType = iota
	CommentIndex
)

type IndexType

type IndexType int

IndexType represents the indexing method used by an index

const (
	BTree IndexType = iota
	Hash
)

func (IndexType) String

func (t IndexType) String() string

type InputFormatClause

type InputFormatClause struct {
	Format  string
	Options map[string]string
}

InputFormatClause represents the format specification for input data

type Insert

type Insert struct {
	Table           TableReference
	Columns         []Expression
	Values          [][]Expression
	ReturningClause []Expression
}

Insert represents an INSERT statement

func (Insert) Children

func (i Insert) Children() []Node

func (Insert) TokenLiteral

func (i Insert) TokenLiteral() string

type InsertStatement

type InsertStatement struct {
	With       *WithClause
	TableName  string
	Columns    []Expression
	Values     []Expression
	Query      *SelectStatement // For INSERT ... SELECT
	Returning  []Expression
	OnConflict *OnConflict
}

InsertStatement represents an INSERT SQL statement

func GetInsertStatement

func GetInsertStatement() *InsertStatement

GetInsertStatement gets an InsertStatement from the pool

func (InsertStatement) Children

func (i InsertStatement) Children() []Node

func (*InsertStatement) Span

func (i *InsertStatement) Span() models.Span

Span returns the source location span for the InsertStatement

func (InsertStatement) TokenLiteral

func (i InsertStatement) TokenLiteral() string

type Inspector

type Inspector func(Node) bool

Inspector represents an AST visitor that can be used to traverse an AST and invoke a custom function for each node.

func (Inspector) Visit

func (f Inspector) Visit(node Node) (Visitor, error)

Visit implements the Visitor interface.

type IntegerType

type IntegerType struct {
	Length   *uint64
	Unsigned bool
}

Basic data types

func (*IntegerType) String

func (t *IntegerType) String() string

type JoinClause

type JoinClause struct {
	Type      string // INNER, LEFT, RIGHT, FULL
	Left      TableReference
	Right     TableReference
	Condition Expression
}

JoinClause represents a JOIN clause in SQL

func (JoinClause) Children

func (j JoinClause) Children() []Node

func (JoinClause) TokenLiteral

func (j JoinClause) TokenLiteral() string

type JsonType

type JsonType struct{}

Basic data types

func (*JsonType) String

func (*JsonType) String() string

type ListExpression

type ListExpression struct {
	Values []Expression
}

ListExpression represents a list of expressions (1, 2, 3)

func (ListExpression) Children

func (l ListExpression) Children() []Node

func (ListExpression) TokenLiteral

func (l ListExpression) TokenLiteral() string

type LiteralValue

type LiteralValue struct {
	Value interface{}
	Type  string // INTEGER, FLOAT, STRING, BOOLEAN, NULL, etc.
}

LiteralValue represents a literal value in SQL

func GetLiteralValue

func GetLiteralValue() *LiteralValue

GetLiteralValue gets a LiteralValue from the pool

func (LiteralValue) Children

func (l LiteralValue) Children() []Node

func (LiteralValue) TokenLiteral

func (l LiteralValue) TokenLiteral() string

type Location

type Location struct {
	Line   int
	Column int
}

Location represents a source location

func (Location) String

func (l Location) String() string

String implements fmt.Stringer

type Node

type Node interface {
	TokenLiteral() string
	Children() []Node
}

Node represents any node in the AST

type NormalizationForm

type NormalizationForm int

NormalizationForm represents Unicode normalization forms

const (
	NFC NormalizationForm = iota
	NFD
	NFKC
	NFKD
)

func (NormalizationForm) String

func (n NormalizationForm) String() string

type NullsDistinctOption

type NullsDistinctOption int

NullsDistinctOption represents Postgres unique index nulls handling

const (
	NullsDistinctNone NullsDistinctOption = iota
	NullsDistinct
	NullsNotDistinct
)

func (NullsDistinctOption) String

func (opt NullsDistinctOption) String() string

type Number

type Number struct {
	Value string
	Long  bool
}

Number represents a numeric value with a flag indicating if it's a long

type NumericType

type NumericType struct {
	Info *ExactNumberInfo
}

Basic data types

func (*NumericType) String

func (t *NumericType) String() string

type ObjectName

type ObjectName struct {
	Name string
}

ObjectName represents a qualified or unqualified object name

func (ObjectName) Children

func (o ObjectName) Children() []Node

func (ObjectName) String

func (o ObjectName) String() string

func (ObjectName) TokenLiteral

func (o ObjectName) TokenLiteral() string

type OnCommit

type OnCommit int

OnCommit represents the ON COMMIT behavior for temporary tables

const (
	OnCommitNone OnCommit = iota
	OnCommitDelete
	OnCommitPreserve
)

type OnConflict

type OnConflict struct {
	Target     []Expression // Target columns
	Constraint string       // Optional constraint name
	Action     OnConflictAction
}

OnConflict represents ON CONFLICT DO UPDATE/NOTHING clause

func (OnConflict) Children

func (o OnConflict) Children() []Node

func (OnConflict) TokenLiteral

func (o OnConflict) TokenLiteral() string

type OnConflictAction

type OnConflictAction struct {
	DoNothing bool
	DoUpdate  []UpdateExpression
	Where     Expression
}

OnConflictAction represents DO UPDATE/NOTHING in ON CONFLICT clause

type OneOrManyWithParens

type OneOrManyWithParens[T any] struct {
	Items []T
}

OneOrManyWithParens represents a list of items enclosed in parentheses

func (*OneOrManyWithParens[T]) Children

func (o *OneOrManyWithParens[T]) Children() []Node

func (*OneOrManyWithParens[T]) TokenLiteral

func (o *OneOrManyWithParens[T]) TokenLiteral() string

type Partition

type Partition struct {
	Name    string
	Columns []*Ident
}

Partition represents table partitioning information

type PartitionBy

type PartitionBy struct {
	Type     string // RANGE, LIST, HASH
	Columns  []string
	Boundary []Expression
}

PartitionBy represents a PARTITION BY clause

func (PartitionBy) Children

func (p PartitionBy) Children() []Node

func (PartitionBy) TokenLiteral

func (p PartitionBy) TokenLiteral() string

type PositionExpression

type PositionExpression struct {
	Substr Expression
	Str    Expression
}

PositionExpression represents POSITION(substr IN str)

func (PositionExpression) Children

func (p PositionExpression) Children() []Node

func (PositionExpression) TokenLiteral

func (p PositionExpression) TokenLiteral() string

type Query

type Query struct {
	Text string
}

Query represents a SQL query

func (*Query) Children

func (q *Query) Children() []Node

func (*Query) TokenLiteral

func (q *Query) TokenLiteral() string

type ReferenceDefinition

type ReferenceDefinition struct {
	Table    string
	Columns  []string
	OnDelete string
	OnUpdate string
	Match    string
}

ReferenceDefinition represents a REFERENCES clause

func (ReferenceDefinition) Children

func (r ReferenceDefinition) Children() []Node

func (*ReferenceDefinition) String

func (r *ReferenceDefinition) String() string

String returns a string representation of a ReferenceDefinition

func (ReferenceDefinition) TokenLiteral

func (r ReferenceDefinition) TokenLiteral() string

type RoleOption

type RoleOption struct {
	Name  string
	Type  RoleOptionType
	Value interface{} // Can be bool or Expression depending on Type
}

RoleOption represents an option in ROLE statement

func (*RoleOption) String

func (opt *RoleOption) String() string

type RoleOptionType

type RoleOptionType int
const (
	BypassRLS RoleOptionType = iota
	ConnectionLimit
	CreateDB
	CreateRole
	Inherit
	Login
	Password
	Replication
	SuperUser
	ValidUntil
)

type RowAccessPolicy

type RowAccessPolicy struct {
	Name    string
	Filter  Expr
	Enabled bool
}

RowAccessPolicy represents row-level access policy

func (*RowAccessPolicy) Children

func (r *RowAccessPolicy) Children() []Node

func (*RowAccessPolicy) TokenLiteral

func (r *RowAccessPolicy) TokenLiteral() string

type Select

type Select struct {
	Distinct bool
	Columns  []Expression
	From     []TableReference
	Where    Expression
	GroupBy  []Expression
	Having   Expression
	OrderBy  []Expression
	Limit    *int64
	Offset   *int64
}

Select represents a SELECT statement

func (Select) Children

func (s Select) Children() []Node

func (Select) TokenLiteral

func (s Select) TokenLiteral() string

type SelectStatement

type SelectStatement struct {
	With      *WithClause
	Distinct  bool
	Columns   []Expression
	From      []TableReference
	TableName string // Added for pool operations
	Joins     []JoinClause
	Where     Expression
	GroupBy   []Expression
	Having    Expression
	Windows   []WindowSpec
	OrderBy   []Expression
	Limit     *int
	Offset    *int
}

SelectStatement represents a SELECT SQL statement

func GetSelectStatement

func GetSelectStatement() *SelectStatement

GetSelectStatement gets a SelectStatement from the pool

func (SelectStatement) Children

func (s SelectStatement) Children() []Node

func (*SelectStatement) Span

func (s *SelectStatement) Span() models.Span

Span returns the source location span for the SelectStatement

func (SelectStatement) TokenLiteral

func (s SelectStatement) TokenLiteral() string

type SetOperation

type SetOperation struct {
	Left     Statement
	Operator string // UNION, EXCEPT, INTERSECT
	Right    Statement
	All      bool // UNION ALL vs UNION
}

SetOperation represents set operations (UNION, EXCEPT, INTERSECT) between two statements. It supports the ALL modifier (e.g., UNION ALL) and proper left-associative parsing. Phase 2 Complete: Full parser support with left-associative precedence.

func (SetOperation) Children

func (s SetOperation) Children() []Node

func (SetOperation) TokenLiteral

func (s SetOperation) TokenLiteral() string

type SetType

type SetType struct {
	Values []string
}

Basic data types

func (*SetType) String

func (t *SetType) String() string

type Setting

type Setting struct {
	Column *Ident
	Value  Expression
}

Setting represents a SET clause in an UPDATE statement

type Span

type Span struct {
	Start Location
	End   Location
}

Span represents a source location span

func (Span) String

func (s Span) String() string

String implements fmt.Stringer

type Spanned

type Spanned interface {
	// Span returns the source location span for this node
	Span() models.Span
}

Spanned represents an AST node that has source location information

type SpannedNode

type SpannedNode struct {
	// contains filtered or unexported fields
}

SpannedNode represents a basic AST node with source location information

func (*SpannedNode) SetSpan

func (n *SpannedNode) SetSpan(span models.Span)

SetSpan sets the source location span for this node

func (*SpannedNode) Span

func (n *SpannedNode) Span() models.Span

Span returns the source location span for this node

type SqlOption

type SqlOption struct {
	Name  string
	Value string
}

SqlOption represents SQL-specific options

type StageLoadSelectItem

type StageLoadSelectItem struct {
	Alias      *Ident
	FileColNum int32
	Element    *Ident
	ItemAs     *Ident
}

StageLoadSelectItem represents a select item in stage loading operations

func (*StageLoadSelectItem) String

func (s *StageLoadSelectItem) String() string

String implements the Stringer interface for StageLoadSelectItem

type StageParamsObject

type StageParamsObject struct {
	URL                *string
	Encryption         DataLoadingOptions
	Endpoint           *string
	StorageIntegration *string
	Credentials        DataLoadingOptions
}

StageParamsObject represents parameters for stage operations in data loading

func (*StageParamsObject) String

func (s *StageParamsObject) String() string

String implements the Stringer interface for StageParamsObject

type Statement

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

Statement represents a SQL statement

type StatementImpl

type StatementImpl struct {
	Variant StatementVariant
}

StatementImpl represents a concrete implementation of a SQL statement

func (*StatementImpl) Children

func (s *StatementImpl) Children() []Node

func (*StatementImpl) TokenLiteral

func (s *StatementImpl) TokenLiteral() string

type StatementVariant

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

StatementVariant represents a specific type of SQL statement

type StorageSerializationPolicy

type StorageSerializationPolicy int

StorageSerializationPolicy represents storage serialization policy

const (
	StorageSerializationNone StorageSerializationPolicy = iota
	StorageSerializationJSON
	StorageSerializationAvro
)

type StructBracketKind

type StructBracketKind int

StructBracketKind represents the type of brackets used in STRUCT type

const (
	ParenthesesBrackets StructBracketKind = iota
	AngleBracketsBrackets
)

type StructField

type StructField struct {
	Name string
	Type string
	Tags map[string]string
}

StructField represents a field in a struct type

func GetStructFields

func GetStructFields(t reflect.Type) []StructField

GetStructFields returns the fields of a struct type

type SubstringExpression

type SubstringExpression struct {
	Str    Expression
	Start  Expression
	Length Expression
}

SubstringExpression represents SUBSTRING(str FROM start [FOR length])

func (SubstringExpression) Children

func (s SubstringExpression) Children() []Node

func (SubstringExpression) TokenLiteral

func (s SubstringExpression) TokenLiteral() string

type Table

type Table struct {
	Name        string
	Columns     []*ColumnDef
	Constraints []*TableConstraint
	Options     map[string]string
}

Table represents a table definition

type TableConstraint

type TableConstraint struct {
	Name       string
	Type       string // PRIMARY KEY, UNIQUE, FOREIGN KEY, CHECK
	Columns    []string
	References *ReferenceDefinition
	Check      Expression
}

TableConstraint represents a table constraint

func (TableConstraint) Children

func (t TableConstraint) Children() []Node

func (TableConstraint) TokenLiteral

func (t TableConstraint) TokenLiteral() string

type TableEngine

type TableEngine string

TableEngine represents the storage engine for a table

type TableOption

type TableOption struct {
	Name  string
	Value string
}

TableOption represents table options like ENGINE, CHARSET, etc.

func (TableOption) Children

func (t TableOption) Children() []Node

func (TableOption) TokenLiteral

func (t TableOption) TokenLiteral() string

type TableReference

type TableReference struct {
	Name  string
	Alias string
}

TableReference represents a table in FROM clause

func (TableReference) Children

func (t TableReference) Children() []Node

func (TableReference) TokenLiteral

func (t TableReference) TokenLiteral() string

type TableType

type TableType struct {
	Columns []*ColumnDef
}

Basic data types

func (*TableType) String

func (t *TableType) String() string

String implementations for data types

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag represents a key-value metadata tag

type TimeType

type TimeType struct {
	Precision *uint64
	Timezone  TimezoneInfo
}

Basic data types

func (*TimeType) String

func (t *TimeType) String() string

type TimestampType

type TimestampType struct {
	Precision *uint64
	Timezone  TimezoneInfo
}

Basic data types

func (*TimestampType) String

func (t *TimestampType) String() string

type TimezoneInfo

type TimezoneInfo int

TimezoneInfo represents timezone information for temporal types

const (
	NoTimezone TimezoneInfo = iota
	WithTimeZone
	WithoutTimeZone
	Tz
)

func (TimezoneInfo) String

func (t TimezoneInfo) String() string

type Token

type Token struct {
	Type TokenType
}

Token represents a lexical token

func (Token) String

func (t Token) String() string

String implements fmt.Stringer

type TokenType

type TokenType int

TokenType represents the type of a token

const (
	EOF TokenType = iota
	Comma
	Period
)

Token types

type TokenWithSpan

type TokenWithSpan struct {
	Token Token
	Span  Span
}

TokenWithSpan represents a token with its source location span

func NewTokenWithSpan

func NewTokenWithSpan(token Token, span Span) TokenWithSpan

NewTokenWithSpan creates a new TokenWithSpan

func NewTokenWithSpanEOF

func NewTokenWithSpanEOF() TokenWithSpan

NewTokenWithSpanEOF creates a new EOF TokenWithSpan

func (TokenWithSpan) GoString

func (t TokenWithSpan) GoString() string

GoString implements fmt.GoStringer

func (TokenWithSpan) String

func (t TokenWithSpan) String() string

String implements fmt.Stringer

type TriggerEvent

type TriggerEvent struct {
	Type    TriggerEventType
	Columns []Identifier // Only used for UPDATE events
}

TriggerEvent describes trigger events

func (TriggerEvent) Children

func (t TriggerEvent) Children() []Node

func (TriggerEvent) String

func (t TriggerEvent) String() string

func (TriggerEvent) TokenLiteral

func (t TriggerEvent) TokenLiteral() string

type TriggerEventType

type TriggerEventType int
const (
	TriggerEventInsert TriggerEventType = iota
	TriggerEventUpdate
	TriggerEventDelete
	TriggerEventTruncate
)

type TriggerExecBody

type TriggerExecBody struct {
	ExecType TriggerExecBodyType
	FuncDesc FunctionDesc
}

TriggerExecBody represents the execution body of a trigger

func (TriggerExecBody) Children

func (t TriggerExecBody) Children() []Node

func (TriggerExecBody) String

func (t TriggerExecBody) String() string

func (TriggerExecBody) TokenLiteral

func (t TriggerExecBody) TokenLiteral() string

type TriggerExecBodyType

type TriggerExecBodyType int

TriggerExecBodyType represents types of trigger body execution

const (
	TriggerExecBodyFunction TriggerExecBodyType = iota
	TriggerExecBodyProcedure
)

func (TriggerExecBodyType) String

func (t TriggerExecBodyType) String() string

type TriggerObject

type TriggerObject int

TriggerObject specifies whether the trigger function should be fired once for every row affected by the trigger event, or just once per SQL statement.

const (
	TriggerObjectRow TriggerObject = iota
	TriggerObjectStatement
)

func (TriggerObject) Children

func (t TriggerObject) Children() []Node

Implement Node interface for trigger types

func (TriggerObject) String

func (t TriggerObject) String() string

func (TriggerObject) TokenLiteral

func (t TriggerObject) TokenLiteral() string

type TriggerPeriod

type TriggerPeriod int

TriggerPeriod represents when the trigger should be executed

const (
	TriggerPeriodAfter TriggerPeriod = iota
	TriggerPeriodBefore
	TriggerPeriodInsteadOf
)

func (TriggerPeriod) Children

func (t TriggerPeriod) Children() []Node

func (TriggerPeriod) String

func (t TriggerPeriod) String() string

func (TriggerPeriod) TokenLiteral

func (t TriggerPeriod) TokenLiteral() string

type TriggerReferencing

type TriggerReferencing struct {
	ReferType              TriggerReferencingType
	IsAs                   bool
	TransitionRelationName ObjectName
}

TriggerReferencing represents a declaration of relation names that provide access to the transition relations of the triggering statement

func (TriggerReferencing) Children

func (t TriggerReferencing) Children() []Node

func (TriggerReferencing) String

func (t TriggerReferencing) String() string

func (TriggerReferencing) TokenLiteral

func (t TriggerReferencing) TokenLiteral() string

type TriggerReferencingType

type TriggerReferencingType int

TriggerReferencingType indicates whether the following relation name is for the before-image transition relation or the after-image transition relation

const (
	TriggerReferencingOldTable TriggerReferencingType = iota
	TriggerReferencingNewTable
)

func (TriggerReferencingType) String

func (t TriggerReferencingType) String() string

type TrimWhereField

type TrimWhereField int

TrimWhereField represents the type of trimming operation

const (
	Both TrimWhereField = iota
	Leading
	Trailing
)

func (TrimWhereField) String

func (t TrimWhereField) String() string

type UnaryExpression

type UnaryExpression struct {
	Operator UnaryOperator
	Expr     Expression
}

UnaryExpression represents operations like NOT expr

func (UnaryExpression) Children

func (u UnaryExpression) Children() []Node

func (*UnaryExpression) Span

func (e *UnaryExpression) Span() models.Span

func (*UnaryExpression) TokenLiteral

func (u *UnaryExpression) TokenLiteral() string

type UnaryOperator

type UnaryOperator int

UnaryOperator represents unary operators in SQL expressions

const (
	// Plus represents unary plus operator, e.g. +9
	Plus UnaryOperator = iota
	// Minus represents unary minus operator, e.g. -9
	Minus
	// Not represents logical NOT operator, e.g. NOT(true)
	Not
	// PGBitwiseNot represents PostgreSQL bitwise NOT operator, e.g. ~9
	PGBitwiseNot
	// PGSquareRoot represents PostgreSQL square root operator, e.g. |/9
	PGSquareRoot
	// PGCubeRoot represents PostgreSQL cube root operator, e.g. ||/27
	PGCubeRoot
	// PGPostfixFactorial represents PostgreSQL postfix factorial operator, e.g. 9!
	PGPostfixFactorial
	// PGPrefixFactorial represents PostgreSQL prefix factorial operator, e.g. !!9
	PGPrefixFactorial
	// PGAbs represents PostgreSQL absolute value operator, e.g. @ -9
	PGAbs
	// BangNot represents Hive-specific logical NOT operator, e.g. ! false
	BangNot
)

func (UnaryOperator) String

func (op UnaryOperator) String() string

String returns the string representation of the unary operator

type Update

type Update struct {
	Table           TableReference
	Updates         []UpdateExpression
	Where           Expression
	ReturningClause []Expression
}

Update represents an UPDATE statement

func (Update) Children

func (u Update) Children() []Node

func (Update) TokenLiteral

func (u Update) TokenLiteral() string

type UpdateExpression

type UpdateExpression struct {
	Column Expression
	Value  Expression
}

UpdateExpression represents a column=value expression in UPDATE

func GetUpdateExpression

func GetUpdateExpression() *UpdateExpression

GetUpdateExpression gets an UpdateExpression from the pool

func (UpdateExpression) Children

func (u UpdateExpression) Children() []Node

func (UpdateExpression) TokenLiteral

func (u UpdateExpression) TokenLiteral() string

type UpdateStatement

type UpdateStatement struct {
	With        *WithClause
	TableName   string
	Alias       string
	Updates     []UpdateExpression // Keep for backward compatibility
	Assignments []UpdateExpression // New field for consistency with span.go
	From        []TableReference
	Where       Expression
	Returning   []Expression
}

UpdateStatement represents an UPDATE SQL statement

func GetUpdateStatement

func GetUpdateStatement() *UpdateStatement

GetUpdateStatement gets an UpdateStatement from the pool

func (UpdateStatement) Children

func (u UpdateStatement) Children() []Node

func (*UpdateStatement) Span

func (u *UpdateStatement) Span() models.Span

Span returns the source location span for the UpdateStatement

func (UpdateStatement) TokenLiteral

func (u UpdateStatement) TokenLiteral() string

type UpsertClause

type UpsertClause struct {
	Updates []UpdateExpression
}

UpsertClause represents INSERT ... ON DUPLICATE KEY UPDATE

func (UpsertClause) Children

func (u UpsertClause) Children() []Node

func (UpsertClause) TokenLiteral

func (u UpsertClause) TokenLiteral() string

type Value

type Value struct {
	Type  ValueType
	Value interface{}
}

Value represents primitive SQL values such as number and string

func (Value) Children

func (v Value) Children() []Node

func (Value) String

func (v Value) String() string

func (Value) TokenLiteral

func (v Value) TokenLiteral() string

type ValueType

type ValueType int

ValueType represents the type of a SQL value

const (
	NumberValue ValueType = iota
	SingleQuotedStringValue
	DollarQuotedStringValue
	TripleSingleQuotedStringValue
	TripleDoubleQuotedStringValue
	EscapedStringLiteralValue
	UnicodeStringLiteralValue
	SingleQuotedByteStringLiteralValue
	DoubleQuotedByteStringLiteralValue
	TripleSingleQuotedByteStringLiteralValue
	TripleDoubleQuotedByteStringLiteralValue
	SingleQuotedRawStringLiteralValue
	DoubleQuotedRawStringLiteralValue
	TripleSingleQuotedRawStringLiteralValue
	TripleDoubleQuotedRawStringLiteralValue
	NationalStringLiteralValue
	HexStringLiteralValue
	DoubleQuotedStringValue
	BooleanValue
	NullValue
	PlaceholderValue
)

type Values

type Values struct {
	Rows [][]Expression
}

Values represents VALUES clause

func (Values) Children

func (v Values) Children() []Node

func (Values) TokenLiteral

func (v Values) TokenLiteral() string

type VarcharType

type VarcharType struct {
	Length *CharacterLength
}

Basic data types

func (*VarcharType) String

func (t *VarcharType) String() string

type VisitFunc

type VisitFunc func(Node) (Visitor, error)

VisitFunc is a function type that can be used to implement custom visitors without creating a new type.

func (VisitFunc) Visit

func (f VisitFunc) Visit(node Node) (Visitor, error)

Visit implements the Visitor interface.

type Visitor

type Visitor interface {
	Visit(node Node) (w Visitor, err error)
}

Visitor defines an interface for traversing the AST. The Visit method is called for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).

type WhenClause

type WhenClause struct {
	Condition Expression
	Result    Expression
}

WhenClause represents WHEN ... THEN ... in CASE expression

func (WhenClause) Children

func (w WhenClause) Children() []Node

func (WhenClause) TokenLiteral

func (w WhenClause) TokenLiteral() string

type WindowFrame

type WindowFrame struct {
	Type  string // ROWS, RANGE
	Start WindowFrameBound
	End   *WindowFrameBound
}

WindowFrame represents window frame clause

func (WindowFrame) Children

func (w WindowFrame) Children() []Node

func (WindowFrame) TokenLiteral

func (w WindowFrame) TokenLiteral() string

type WindowFrameBound

type WindowFrameBound struct {
	Type  string // CURRENT ROW, UNBOUNDED PRECEDING, etc.
	Value Expression
}

WindowFrameBound represents window frame bound

type WindowSpec

type WindowSpec struct {
	Name        string
	PartitionBy []Expression
	OrderBy     []Expression
	FrameClause *WindowFrame
}

WindowSpec represents a window specification

func (WindowSpec) Children

func (w WindowSpec) Children() []Node

func (WindowSpec) TokenLiteral

func (w WindowSpec) TokenLiteral() string

type WithClause

type WithClause struct {
	Recursive bool
	CTEs      []*CommonTableExpr
}

WithClause represents a WITH clause in a SQL statement. It supports both simple and recursive Common Table Expressions (CTEs). Phase 2 Complete: Full parser integration with all statement types.

func (WithClause) Children

func (w WithClause) Children() []Node

func (WithClause) TokenLiteral

func (w WithClause) TokenLiteral() string

type WrappedCollection

type WrappedCollection[T any] struct {
	Items   []T
	Wrapper string
}

WrappedCollection represents a collection of items with optional wrapper

func (*WrappedCollection[T]) Children

func (w *WrappedCollection[T]) Children() []Node

func (*WrappedCollection[T]) TokenLiteral

func (w *WrappedCollection[T]) TokenLiteral() string

Jump to

Keyboard shortcuts

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