parser

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2021 Molecula Corp. All rights reserved.

Copyright 2021 Molecula Corp. All rights reserved.

Copyright 2021 Molecula Corp. All rights reserved.

Copyright 2021 Molecula Corp. All rights reserved.

Copyright 2021 Molecula Corp. All rights reserved.

Index

Constants

View Source
const (
	LowestPrec  = 0 // non-operators
	UnaryPrec   = 13
	HighestPrec = 14
)

Variables

This section is empty.

Functions

func ExprString

func ExprString(expr Expr) string

ExprString returns the string representation of expr. Returns a blank string if expr is nil.

func ForEachSource

func ForEachSource(src Source, fn func(Source) bool)

ForEachSource calls fn for every source within the current scope. Stops iteration if fn returns false.

func IdentName

func IdentName(ident *Ident) string

IdentName returns the name of ident. Returns a blank string if ident is nil.

func IsValidTypeName

func IsValidTypeName(typeName string) bool

func NumDecimalPlaces

func NumDecimalPlaces(v string) int

Types

type AlterDatabaseStatement added in v3.32.0

type AlterDatabaseStatement struct {
	Alter    Pos    // position of ALTER keyword
	Database Pos    // position of DATABASE keyword
	Name     *Ident // database name

	With Pos // position of WITH keyword

	Option DatabaseOption
}

func (*AlterDatabaseStatement) Clone added in v3.32.0

Clone returns a deep copy of s.

func (*AlterDatabaseStatement) String added in v3.32.0

func (s *AlterDatabaseStatement) String() string

String returns the string representation of the statement.

type AlterTableStatement

type AlterTableStatement struct {
	Alter Pos    // position of ALTER keyword
	Table Pos    // position of TABLE keyword
	Name  *Ident // table name

	Rename Pos // position of RENAME keyword

	RenameColumn  Pos    // position of COLUMN keyword after RENAME
	OldColumnName *Ident // old column name
	To            Pos    // position of TO keyword
	NewColumnName *Ident // new column name

	Add       Pos               // position of ADD keyword
	AddColumn Pos               // position of COLUMN keyword after ADD
	ColumnDef *ColumnDefinition // new column definition

	Drop           Pos    // position of ADD keyword
	DropColumn     Pos    // position of COLUMN keyword after ADD
	DropColumnName *Ident // drop column name
}

func (*AlterTableStatement) Clone

Clone returns a deep copy of s.

func (*AlterTableStatement) String

func (s *AlterTableStatement) String() string

String returns the string representation of the statement.

type AlterViewStatement added in v3.29.0

type AlterViewStatement struct {
	Alter Pos    // position of CREATE keyword
	View  Pos    // position of VIEW keyword
	Name  *Ident // view name

	// TODO(pok) - we'll do this later - see note in parseCompileView()
	// Lparen  Pos              // position of column list left paren
	// Columns []*Ident         // column list
	// Rparen  Pos              // position of column list right paren
	As     Pos              // position of AS keyword
	Select *SelectStatement // source statement
}

func (*AlterViewStatement) Clone added in v3.29.0

Clone returns a deep copy of s.

func (*AlterViewStatement) String added in v3.29.0

func (s *AlterViewStatement) String() string

String returns the string representation of the statement.

type AnalyzeStatement

type AnalyzeStatement struct {
	Analyze Pos    // position of ANALYZE keyword
	Name    *Ident // table name
}

func (*AnalyzeStatement) Clone

func (s *AnalyzeStatement) Clone() *AnalyzeStatement

Clone returns a deep copy of s.

func (*AnalyzeStatement) String

func (s *AnalyzeStatement) String() string

String returns the string representation of the statement.

type Assignment

type Assignment struct {
	Lparen  Pos      // position of column list left paren
	Columns []*Ident // column list
	Rparen  Pos      // position of column list right paren
	Eq      Pos      // position of =
	Expr    Expr     // assigned expression
}

Assignment is used within the UPDATE statement & upsert clause. It is similiar to an expression except that it must be an equality.

func (*Assignment) Clone

func (a *Assignment) Clone() *Assignment

Clone returns a deep copy of a.

func (*Assignment) String

func (a *Assignment) String() string

String returns the string representation of the clause.

type BeginStatement

type BeginStatement struct {
	Begin       Pos // position of BEGIN
	Deferred    Pos // position of DEFERRED keyword
	Immediate   Pos // position of IMMEDIATE keyword
	Exclusive   Pos // position of EXCLUSIVE keyword
	Transaction Pos // position of TRANSACTION keyword  (optional)
}

func (*BeginStatement) Clone

func (s *BeginStatement) Clone() *BeginStatement

Clone returns a deep copy of s.

func (*BeginStatement) String

func (s *BeginStatement) String() string

String returns the string representation of the statement.

type BinaryExpr

type BinaryExpr struct {
	X     Expr  // lhs
	OpPos Pos   // position of Op
	Op    Token // operator
	Y     Expr  // rhs

	ResultDataType ExprDataType
}

func (*BinaryExpr) Clone

func (expr *BinaryExpr) Clone() *BinaryExpr

Clone returns a deep copy of expr.

func (*BinaryExpr) DataType

func (expr *BinaryExpr) DataType() ExprDataType

func (*BinaryExpr) IsLiteral

func (expr *BinaryExpr) IsLiteral() bool

func (*BinaryExpr) Pos

func (expr *BinaryExpr) Pos() Pos

func (*BinaryExpr) String

func (expr *BinaryExpr) String() string

String returns the string representation of the expression.

type BoolLit

type BoolLit struct {
	ValuePos Pos  // literal position
	Value    bool // literal value
}

func (*BoolLit) Clone

func (lit *BoolLit) Clone() *BoolLit

Clone returns a deep copy of lit.

func (*BoolLit) DataType

func (expr *BoolLit) DataType() ExprDataType

func (*BoolLit) IsLiteral

func (expr *BoolLit) IsLiteral() bool

func (*BoolLit) Pos

func (expr *BoolLit) Pos() Pos

func (*BoolLit) String

func (lit *BoolLit) String() string

String returns the string representation of the expression.

type BulkInsertMapDefinition

type BulkInsertMapDefinition struct {
	Name    *Ident // map name
	Type    *Type  // data type
	MapExpr Expr
}

func (*BulkInsertMapDefinition) Clone

Clone returns a deep copy of d.

func (*BulkInsertMapDefinition) String

func (c *BulkInsertMapDefinition) String() string

String returns the string representation of the statement.

type BulkInsertStatement

type BulkInsertStatement struct {
	Bulk    Pos // position of BULK keyword
	Insert  Pos // position of INSERT keyword
	Replace Pos // position of REPLACE keyword
	Into    Pos // position of INTO keyword

	Table *Ident // table name

	ColumnsLparen Pos      // position of column list left paren
	Columns       []*Ident // optional column list
	ColumnsRparen Pos      // position of column list right paren

	Map       Pos                        // position of MAP keyword
	MapLparen Pos                        // position of column list left paren
	MapList   []*BulkInsertMapDefinition // source to column map
	MapRparen Pos                        // position of column list right paren

	Transform       Pos    // position of MAP keyword
	TransformLparen Pos    // position of column list left paren
	TransformList   []Expr // source to column map
	TransformRparen Pos    // position of column list right paren

	From               Pos  // position of FROM keyword
	DataSource         Expr // data source
	With               Pos  // position of WITH keyword
	BatchSize          Expr
	RowsLimit          Expr
	Format             Expr
	Input              Expr
	HeaderRow          Expr // has header row (that needs to be skipped)
	AllowMissingValues Expr // allows missing values
}

func (*BulkInsertStatement) String

func (s *BulkInsertStatement) String() string

type CTE

type CTE struct {
	TableName     *Ident           // table name
	ColumnsLparen Pos              // position of column list left paren
	Columns       []*Ident         // optional column list
	ColumnsRparen Pos              // position of column list right paren
	As            Pos              // position of AS keyword
	SelectLparen  Pos              // position of select left paren
	Select        *SelectStatement // select statement
	SelectRparen  Pos              // position of select right paren
}

CTE represents an AST node for a common table expression.

func (*CTE) Clone

func (cte *CTE) Clone() *CTE

Clone returns a deep copy of cte.

func (*CTE) String

func (cte *CTE) String() string

String returns the string representation of the CTE.

type CacheTypeConstraint

type CacheTypeConstraint struct {
	CacheType      Pos // position of CACHETYPE keyword
	CacheTypeValue string
	Size           Pos  // position of SIZE keyword
	SizeExpr       Expr // check expression
}

func (*CacheTypeConstraint) Clone

Clone returns a deep copy of c.

func (*CacheTypeConstraint) String

func (c *CacheTypeConstraint) String() string

String returns the string representation of the constraint.

type Call

type Call struct {
	Name     *Ident        // function name
	Lparen   Pos           // position of left paren
	Star     Pos           // position of *
	Distinct Pos           // position of DISTINCT keyword
	Args     []Expr        // argument list
	Rparen   Pos           // position of right paren
	Filter   *FilterClause // filter clause
	Over     *OverClause   // over clause

	ResultDataType ExprDataType
}

func (*Call) Clone

func (c *Call) Clone() *Call

Clone returns a deep copy of c.

func (*Call) DataType

func (expr *Call) DataType() ExprDataType

func (*Call) IsLiteral

func (expr *Call) IsLiteral() bool

func (*Call) Pos

func (expr *Call) Pos() Pos

func (*Call) String

func (c *Call) String() string

String returns the string representation of the expression.

type CaseBlock

type CaseBlock struct {
	When      Pos  // position of WHEN keyword
	Condition Expr // block condition
	Then      Pos  // position of THEN keyword
	Body      Expr // result expression
}

func (*CaseBlock) Clone

func (blk *CaseBlock) Clone() *CaseBlock

Clone returns a deep copy of blk.

func (*CaseBlock) DataType

func (expr *CaseBlock) DataType() ExprDataType

func (*CaseBlock) IsLiteral

func (expr *CaseBlock) IsLiteral() bool

func (*CaseBlock) Pos

func (expr *CaseBlock) Pos() Pos

func (*CaseBlock) String

func (b *CaseBlock) String() string

String returns the string representation of the block.

type CaseExpr

type CaseExpr struct {
	Case     Pos          // position of CASE keyword
	Operand  Expr         // optional condition after the CASE keyword
	Blocks   []*CaseBlock // list of WHEN/THEN pairs
	Else     Pos          // position of ELSE keyword
	ElseExpr Expr         // expression used by default case
	End      Pos          // position of END keyword

	ResultDataType ExprDataType
}

func (*CaseExpr) Clone

func (expr *CaseExpr) Clone() *CaseExpr

Clone returns a deep copy of expr.

func (*CaseExpr) DataType

func (expr *CaseExpr) DataType() ExprDataType

func (*CaseExpr) IsLiteral

func (expr *CaseExpr) IsLiteral() bool

func (*CaseExpr) Pos

func (expr *CaseExpr) Pos() Pos

func (*CaseExpr) String

func (expr *CaseExpr) String() string

String returns the string representation of the expression.

type CastExpr

type CastExpr struct {
	Cast   Pos   // position of CAST keyword
	Lparen Pos   // position of left paren
	X      Expr  // target expression
	As     Pos   // position of AS keyword
	Type   *Type // cast type
	Rparen Pos   // position of right paren

	ResultDataType ExprDataType
}

func (*CastExpr) Clone

func (expr *CastExpr) Clone() *CastExpr

Clone returns a deep copy of expr.

func (*CastExpr) DataType

func (expr *CastExpr) DataType() ExprDataType

func (*CastExpr) IsLiteral

func (expr *CastExpr) IsLiteral() bool

func (*CastExpr) Pos

func (expr *CastExpr) Pos() Pos

func (*CastExpr) String

func (expr *CastExpr) String() string

String returns the string representation of the expression.

type CheckConstraint

type CheckConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name
	Check      Pos    // position of UNIQUE keyword
	Lparen     Pos    // position of left paren
	Expr       Expr   // check expression
	Rparen     Pos    // position of right paren
}

func (*CheckConstraint) Clone

func (c *CheckConstraint) Clone() *CheckConstraint

Clone returns a deep copy of c.

func (*CheckConstraint) String

func (c *CheckConstraint) String() string

String returns the string representation of the constraint.

type ColumnArg

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

type ColumnDefinition

type ColumnDefinition struct {
	Name        *Ident       // column name
	Type        *Type        // data type
	Constraints []Constraint // column constraints
}

func (*ColumnDefinition) Clone

func (d *ColumnDefinition) Clone() *ColumnDefinition

Clone returns a deep copy of d.

func (*ColumnDefinition) String

func (c *ColumnDefinition) String() string

String returns the string representation of the statement.

type CommentOption

type CommentOption struct {
	Comment Pos  // position of COMMENT keyword
	Expr    Expr // expression
}

func (*CommentOption) Clone added in v3.32.0

func (o *CommentOption) Clone() *CommentOption

func (*CommentOption) String

func (o *CommentOption) String() string

type CommitStatement

type CommitStatement struct {
	Commit      Pos // position of COMMIT keyword
	End         Pos // position of END keyword
	Transaction Pos // position of TRANSACTION keyword  (optional)
}

func (*CommitStatement) Clone

func (s *CommitStatement) Clone() *CommitStatement

Clone returns a deep copy of s.

func (*CommitStatement) String

func (s *CommitStatement) String() string

String returns the string representation of the statement.

type Constraint

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

func CloneConstraint

func CloneConstraint(cons Constraint) Constraint

CloneConstraint returns a deep copy cons.

type CreateDatabaseStatement added in v3.32.0

type CreateDatabaseStatement struct {
	Create      Pos    // position of CREATE keyword
	Database    Pos    // position of DATABASE keyword
	If          Pos    // position of IF keyword (optional)
	IfNot       Pos    // position of NOT keyword (optional)
	IfNotExists Pos    // position of EXISTS keyword (optional)
	Name        *Ident // database name

	With Pos // position of WITH keyword

	Options []DatabaseOption // database options
}

func (*CreateDatabaseStatement) Clone added in v3.32.0

Clone returns a deep copy of s.

func (*CreateDatabaseStatement) String added in v3.32.0

func (s *CreateDatabaseStatement) String() string

String returns the string representation of the statement.

type CreateFunctionStatement

type CreateFunctionStatement struct {
	Create      Pos    // position of CREATE keyword
	Function    Pos    // position of FUNCTION keyword
	If          Pos    // position of IF keyword
	IfNot       Pos    // position of NOT keyword after IF
	IfNotExists Pos    // position of EXISTS keyword after IF NOT
	Name        *Ident // index name

	Lparen     Pos                    // position of parameter LParen
	Parameters []*ParameterDefinition // parameters
	Rparen     Pos                    // position of parameter RParen

	Returns   Pos                  // position of RETURNS keyword
	ReturnDef *ParameterDefinition // return def

	As Pos // position of AS keyword

	Begin Pos         // position of BEGIN keyword
	Body  []Statement // function body
	End   Pos         // position of END keyword
}

func (*CreateFunctionStatement) Clone

Clone returns a deep copy of s.

func (*CreateFunctionStatement) String

func (s *CreateFunctionStatement) String() string

String returns the string representation of the statement.

type CreateIndexStatement

type CreateIndexStatement struct {
	Create      Pos              // position of CREATE keyword
	Unique      Pos              // position of optional UNIQUE keyword
	Index       Pos              // position of INDEX keyword
	If          Pos              // position of IF keyword
	IfNot       Pos              // position of NOT keyword after IF
	IfNotExists Pos              // position of EXISTS keyword after IF NOT
	Name        *Ident           // index name
	On          Pos              // position of ON keyword
	Table       *Ident           // index name
	Lparen      Pos              // position of column list left paren
	Columns     []*IndexedColumn // column list
	Rparen      Pos              // position of column list right paren
	Where       Pos              // position of WHERE keyword
	WhereExpr   Expr             // conditional expression
}

func (*CreateIndexStatement) Clone

Clone returns a deep copy of s.

func (*CreateIndexStatement) String

func (s *CreateIndexStatement) String() string

String returns the string representation of the statement.

type CreateTableStatement

type CreateTableStatement struct {
	Create      Pos    // position of CREATE keyword
	Table       Pos    // position of TABLE keyword
	If          Pos    // position of IF keyword (optional)
	IfNot       Pos    // position of NOT keyword (optional)
	IfNotExists Pos    // position of EXISTS keyword (optional)
	Name        *Ident // table name

	Lparen      Pos                 // position of left paren of column list
	Columns     []*ColumnDefinition // column definitions
	Constraints []Constraint        // table constraints
	Rparen      Pos                 // position of right paren of column list

	As      Pos              // position of AS keyword (optional)
	Select  *SelectStatement // select stmt to build from
	Options []TableOption    // table options
}

func (*CreateTableStatement) Clone

Clone returns a deep copy of s.

func (*CreateTableStatement) String

func (s *CreateTableStatement) String() string

String returns the string representation of the statement.

type CreateViewStatement

type CreateViewStatement struct {
	Create      Pos    // position of CREATE keyword
	View        Pos    // position of VIEW keyword
	If          Pos    // position of IF keyword
	IfNot       Pos    // position of NOT keyword after IF
	IfNotExists Pos    // position of EXISTS keyword after IF NOT
	Name        *Ident // view name
	// TODO(pok) - we'll do this later - see note in parseCompileView()
	// Lparen      Pos              // position of column list left paren
	// Columns     []*Ident         // column list
	// Rparen      Pos              // position of column list right paren
	As     Pos              // position of AS keyword
	Select *SelectStatement // source statement
}

func (*CreateViewStatement) Clone

Clone returns a deep copy of s.

func (*CreateViewStatement) String

func (s *CreateViewStatement) String() string

String returns the string representation of the statement.

type DataTypeBool

type DataTypeBool struct {
}

func NewDataTypeBool

func NewDataTypeBool() *DataTypeBool

func (*DataTypeBool) BaseTypeName

func (*DataTypeBool) BaseTypeName() string

func (*DataTypeBool) TypeDescription

func (dt *DataTypeBool) TypeDescription() string

func (*DataTypeBool) TypeInfo

func (*DataTypeBool) TypeInfo() map[string]interface{}

type DataTypeDecimal

type DataTypeDecimal struct {
	Scale int64
}

func NewDataTypeDecimal

func NewDataTypeDecimal(scale int64) *DataTypeDecimal

func (*DataTypeDecimal) BaseTypeName

func (d *DataTypeDecimal) BaseTypeName() string

func (*DataTypeDecimal) TypeDescription

func (d *DataTypeDecimal) TypeDescription() string

func (*DataTypeDecimal) TypeInfo

func (d *DataTypeDecimal) TypeInfo() map[string]interface{}

type DataTypeID

type DataTypeID struct {
}

func NewDataTypeID

func NewDataTypeID() *DataTypeID

func (*DataTypeID) BaseTypeName

func (*DataTypeID) BaseTypeName() string

func (*DataTypeID) TypeDescription

func (dt *DataTypeID) TypeDescription() string

func (*DataTypeID) TypeInfo

func (*DataTypeID) TypeInfo() map[string]interface{}

type DataTypeIDSet

type DataTypeIDSet struct {
}

func NewDataTypeIDSet

func NewDataTypeIDSet() *DataTypeIDSet

func (*DataTypeIDSet) BaseTypeName

func (*DataTypeIDSet) BaseTypeName() string

func (*DataTypeIDSet) TypeDescription

func (dt *DataTypeIDSet) TypeDescription() string

func (*DataTypeIDSet) TypeInfo

func (*DataTypeIDSet) TypeInfo() map[string]interface{}

type DataTypeIDSetQuantum

type DataTypeIDSetQuantum struct {
}

func NewDataTypeIDSetQuantum

func NewDataTypeIDSetQuantum() *DataTypeIDSetQuantum

func (*DataTypeIDSetQuantum) BaseTypeName

func (*DataTypeIDSetQuantum) BaseTypeName() string

func (*DataTypeIDSetQuantum) TypeDescription

func (dt *DataTypeIDSetQuantum) TypeDescription() string

func (*DataTypeIDSetQuantum) TypeInfo

func (*DataTypeIDSetQuantum) TypeInfo() map[string]interface{}

type DataTypeInt

type DataTypeInt struct {
}

func NewDataTypeInt

func NewDataTypeInt() *DataTypeInt

func (*DataTypeInt) BaseTypeName

func (*DataTypeInt) BaseTypeName() string

func (*DataTypeInt) TypeDescription

func (dt *DataTypeInt) TypeDescription() string

func (*DataTypeInt) TypeInfo

func (*DataTypeInt) TypeInfo() map[string]interface{}

type DataTypeRange

type DataTypeRange struct {
	SubscriptType ExprDataType
}

func NewDataTypeRange

func NewDataTypeRange(subscriptType ExprDataType) *DataTypeRange

func (*DataTypeRange) BaseTypeName

func (dt *DataTypeRange) BaseTypeName() string

func (*DataTypeRange) TypeDescription

func (dt *DataTypeRange) TypeDescription() string

func (*DataTypeRange) TypeInfo

func (*DataTypeRange) TypeInfo() map[string]interface{}

type DataTypeString

type DataTypeString struct {
}

func NewDataTypeString

func NewDataTypeString() *DataTypeString

func (*DataTypeString) BaseTypeName

func (*DataTypeString) BaseTypeName() string

func (*DataTypeString) TypeDescription

func (dt *DataTypeString) TypeDescription() string

func (*DataTypeString) TypeInfo

func (*DataTypeString) TypeInfo() map[string]interface{}

type DataTypeStringSet

type DataTypeStringSet struct {
}

func NewDataTypeStringSet

func NewDataTypeStringSet() *DataTypeStringSet

func (*DataTypeStringSet) BaseTypeName

func (*DataTypeStringSet) BaseTypeName() string

func (*DataTypeStringSet) TypeDescription

func (dt *DataTypeStringSet) TypeDescription() string

func (*DataTypeStringSet) TypeInfo

func (*DataTypeStringSet) TypeInfo() map[string]interface{}

type DataTypeStringSetQuantum

type DataTypeStringSetQuantum struct {
}

func NewDataTypeStringSetQuantum

func NewDataTypeStringSetQuantum() *DataTypeStringSetQuantum

func (*DataTypeStringSetQuantum) BaseTypeName

func (*DataTypeStringSetQuantum) BaseTypeName() string

func (*DataTypeStringSetQuantum) TypeDescription

func (dt *DataTypeStringSetQuantum) TypeDescription() string

func (*DataTypeStringSetQuantum) TypeInfo

func (*DataTypeStringSetQuantum) TypeInfo() map[string]interface{}

type DataTypeSubtable

type DataTypeSubtable struct {
	Columns []*SubtableColumn
}

func NewDataTypeSubtable

func NewDataTypeSubtable(columns []*SubtableColumn) *DataTypeSubtable

func (*DataTypeSubtable) BaseTypeName

func (dt *DataTypeSubtable) BaseTypeName() string

func (*DataTypeSubtable) TypeDescription

func (dt *DataTypeSubtable) TypeDescription() string

func (*DataTypeSubtable) TypeInfo

func (*DataTypeSubtable) TypeInfo() map[string]interface{}

type DataTypeTimestamp

type DataTypeTimestamp struct {
}

func NewDataTypeTimestamp

func NewDataTypeTimestamp() *DataTypeTimestamp

func (*DataTypeTimestamp) BaseTypeName

func (*DataTypeTimestamp) BaseTypeName() string

func (*DataTypeTimestamp) TypeDescription

func (dt *DataTypeTimestamp) TypeDescription() string

func (*DataTypeTimestamp) TypeInfo

func (*DataTypeTimestamp) TypeInfo() map[string]interface{}

type DataTypeTuple

type DataTypeTuple struct {
	Members []ExprDataType
}

func NewDataTypeTuple

func NewDataTypeTuple(members []ExprDataType) *DataTypeTuple

func (*DataTypeTuple) BaseTypeName

func (dt *DataTypeTuple) BaseTypeName() string

func (*DataTypeTuple) TypeDescription

func (dt *DataTypeTuple) TypeDescription() string

func (*DataTypeTuple) TypeInfo

func (*DataTypeTuple) TypeInfo() map[string]interface{}

type DataTypeVoid

type DataTypeVoid struct {
}

func NewDataTypeVoid

func NewDataTypeVoid() *DataTypeVoid

func (*DataTypeVoid) BaseTypeName

func (*DataTypeVoid) BaseTypeName() string

func (*DataTypeVoid) TypeDescription

func (dt *DataTypeVoid) TypeDescription() string

func (*DataTypeVoid) TypeInfo

func (*DataTypeVoid) TypeInfo() map[string]interface{}

type DatabaseOption added in v3.32.0

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

type DateLit

type DateLit struct {
	ValuePos Pos       // literal position
	Value    time.Time // literal value
}

func (*DateLit) Clone

func (lit *DateLit) Clone() *DateLit

Clone returns a deep copy of lit.

func (*DateLit) DataType

func (expr *DateLit) DataType() ExprDataType

func (*DateLit) IsLiteral

func (expr *DateLit) IsLiteral() bool

func (*DateLit) Pos

func (expr *DateLit) Pos() Pos

func (*DateLit) String

func (lit *DateLit) String() string

String returns the string representation of the Datetime value.

type DefaultConstraint

type DefaultConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name
	Default    Pos    // position of DEFAULT keyword
	Lparen     Pos    // position of left paren
	Expr       Expr   // default expression
	Rparen     Pos    // position of right paren
}

func (*DefaultConstraint) Clone

Clone returns a deep copy of c.

func (*DefaultConstraint) String

func (c *DefaultConstraint) String() string

String returns the string representation of the constraint.

type DeleteStatement

type DeleteStatement struct {
	//	WithClause *WithClause    // clause containing CTEs
	Delete    Pos                 // position of UPDATE keyword
	From      Pos                 // position of FROM keyword
	TableName *QualifiedTableName // the name of the table we are deleting from
	Source    Source              // source for the delete

	Where     Pos  // position of WHERE keyword
	WhereExpr Expr // conditional expression
}

func (*DeleteStatement) Clone

func (s *DeleteStatement) Clone() *DeleteStatement

Clone returns a deep copy of s.

func (*DeleteStatement) String

func (s *DeleteStatement) String() string

String returns the string representation of the clause.

type DropDatabaseStatement added in v3.32.0

type DropDatabaseStatement struct {
	Drop     Pos    // position of DROP keyword
	Database Pos    // position of DATABASE keyword
	If       Pos    // position of IF keyword
	IfExists Pos    // position of EXISTS keyword after IF
	Name     *Ident // database name
}

func (*DropDatabaseStatement) Clone added in v3.32.0

Clone returns a deep copy of s.

func (*DropDatabaseStatement) String added in v3.32.0

func (s *DropDatabaseStatement) String() string

String returns the string representation of the statement.

type DropFunctionStatement

type DropFunctionStatement struct {
	Drop     Pos    // position of DROP keyword
	Function Pos    // position of FUNCTION keyword
	If       Pos    // position of IF keyword
	IfExists Pos    // position of EXISTS keyword after IF
	Name     *Ident // trigger name
}

func (*DropFunctionStatement) Clone

Clone returns a deep copy of s.

func (*DropFunctionStatement) String

func (s *DropFunctionStatement) String() string

type DropIndexStatement

type DropIndexStatement struct {
	Drop     Pos    // position of DROP keyword
	Index    Pos    // position of INDEX keyword
	If       Pos    // position of IF keyword
	IfExists Pos    // position of EXISTS keyword after IF
	Name     *Ident // index name
}

func (*DropIndexStatement) Clone

Clone returns a deep copy of s.

func (*DropIndexStatement) String

func (s *DropIndexStatement) String() string

String returns the string representation of the statement.

type DropTableStatement

type DropTableStatement struct {
	Drop     Pos    // position of DROP keyword
	Table    Pos    // position of TABLE keyword
	If       Pos    // position of IF keyword
	IfExists Pos    // position of EXISTS keyword after IF
	Name     *Ident // table name
}

func (*DropTableStatement) Clone

Clone returns a deep copy of s.

func (*DropTableStatement) String

func (s *DropTableStatement) String() string

String returns the string representation of the statement.

type DropViewStatement

type DropViewStatement struct {
	Drop     Pos    // position of DROP keyword
	View     Pos    // position of VIEW keyword
	If       Pos    // position of IF keyword
	IfExists Pos    // position of EXISTS keyword after IF
	Name     *Ident // view name
}

func (*DropViewStatement) Clone

Clone returns a deep copy of s.

func (*DropViewStatement) String

func (s *DropViewStatement) String() string

String returns the string representation of the statement.

type Error

type Error struct {
	Pos Pos
	Msg string
}

Error represents a parse error.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type Exists

type Exists struct {
	Not    Pos              // position of optional NOT keyword
	Exists Pos              // position of EXISTS keyword
	Lparen Pos              // position of left paren
	Select *SelectStatement // select statement
	Rparen Pos              // position of right paren
}

func (*Exists) Clone

func (expr *Exists) Clone() *Exists

Clone returns a deep copy of expr.

func (*Exists) DataType

func (expr *Exists) DataType() ExprDataType

func (*Exists) IsLiteral

func (expr *Exists) IsLiteral() bool

func (*Exists) Pos

func (expr *Exists) Pos() Pos

func (*Exists) String

func (expr *Exists) String() string

String returns the string representation of the expression.

type ExplainStatement

type ExplainStatement struct {
	Explain   Pos       // position of EXPLAIN
	Query     Pos       // position of QUERY (optional)
	QueryPlan Pos       // position of PLAN after QUERY (optional)
	Stmt      Statement // target statement
}

func (*ExplainStatement) Clone

func (s *ExplainStatement) Clone() *ExplainStatement

Clone returns a deep copy of s.

func (*ExplainStatement) String

func (s *ExplainStatement) String() string

String returns the string representation of the statement.

type Expr

type Expr interface {
	Node

	IsLiteral() bool
	DataType() ExprDataType
	Pos() Pos
	// contains filtered or unexported methods
}

func CloneExpr

func CloneExpr(expr Expr) Expr

CloneExpr returns a deep copy expr.

func MustParseExprString

func MustParseExprString(s string) Expr

MustParseExprString parses s into an expression. Panic on error.

func ParseExprString

func ParseExprString(s string) (Expr, error)

ParseExprString parses s into an expression. Returns nil if s is blank.

func SplitExprTree

func SplitExprTree(expr Expr) []Expr

SplitExprTree splits apart expr so it is a list of all AND joined expressions. For example, the expression "A AND B AND (C OR (D AND E))" would be split into a list of "A", "B", "C OR (D AND E)".

type ExprDataType

type ExprDataType interface {

	// the base type name e.g. int or decimal
	BaseTypeName() string
	// additional type information - intended to be used outside the language
	// layer (marshalled over json, or otherwise serialized so that consumers
	// have access to complete type information)
	// TypeInfo is not used inside the language layer itself, as the concrete
	// types (e.g. DataTypeString) are used
	TypeInfo() map[string]interface{}
	// the full type specification as a string - intended to be human readable
	TypeDescription() string
	// contains filtered or unexported methods
}

ExprDataType is the interface for all language layer types

type ExprList

type ExprList struct {
	Lparen Pos    // position of left paren
	Exprs  []Expr // list of expressions
	Rparen Pos    // position of right paren
}

func (*ExprList) Clone

func (l *ExprList) Clone() *ExprList

Clone returns a deep copy of l.

func (*ExprList) DataType

func (expr *ExprList) DataType() ExprDataType

func (*ExprList) IsLiteral

func (expr *ExprList) IsLiteral() bool

func (*ExprList) Pos

func (expr *ExprList) Pos() Pos

func (*ExprList) String

func (l *ExprList) String() string

String returns the string representation of the expression.

type FilterClause

type FilterClause struct {
	Filter Pos  // position of FILTER keyword
	Lparen Pos  // position of left paren
	Where  Pos  // position of WHERE keyword
	X      Expr // filter expression
	Rparen Pos  // position of right paren
}

func (*FilterClause) Clone

func (c *FilterClause) Clone() *FilterClause

Clone returns a deep copy of c.

func (*FilterClause) String

func (c *FilterClause) String() string

String returns the string representation of the clause.

type FloatLit

type FloatLit struct {
	ValuePos Pos    // literal position
	Value    string // literal value
}

func (*FloatLit) Clone

func (lit *FloatLit) Clone() *FloatLit

Clone returns a deep copy of lit.

func (*FloatLit) DataType

func (expr *FloatLit) DataType() ExprDataType

func (*FloatLit) IsLiteral

func (expr *FloatLit) IsLiteral() bool

func (*FloatLit) Pos

func (expr *FloatLit) Pos() Pos

func (*FloatLit) String

func (lit *FloatLit) String() string

String returns the string representation of the expression.

type ForeignKeyArg

type ForeignKeyArg struct {
	On         Pos // position of ON keyword
	OnUpdate   Pos // position of the UPDATE keyword
	OnDelete   Pos // position of the DELETE keyword
	Set        Pos // position of the SET keyword
	SetNull    Pos // position of the NULL keyword after SET
	SetDefault Pos // position of the DEFAULT keyword after SET
	Cascade    Pos // position of the CASCADE keyword
	Restrict   Pos // position of the RESTRICT keyword
	No         Pos // position of the NO keyword
	NoAction   Pos // position of the ACTION keyword after NO
}

func (*ForeignKeyArg) Clone

func (arg *ForeignKeyArg) Clone() *ForeignKeyArg

Clone returns a deep copy of arg.

func (*ForeignKeyArg) String

func (c *ForeignKeyArg) String() string

String returns the string representation of the argument.

type ForeignKeyConstraint

type ForeignKeyConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name

	Foreign    Pos      // position of FOREIGN keyword (table only)
	ForeignKey Pos      // position of KEY keyword after FOREIGN (table only)
	Lparen     Pos      // position of left paren (table only)
	Columns    []*Ident // indexed columns (table only)
	Rparen     Pos      // position of right paren (table only)

	References         Pos              // position of REFERENCES keyword
	ForeignTable       *Ident           // foreign table name
	ForeignLparen      Pos              // position of left paren
	ForeignColumns     []*Ident         // column list
	ForeignRparen      Pos              // position of right paren
	Args               []*ForeignKeyArg // arguments
	Deferrable         Pos              // position of DEFERRABLE keyword
	Not                Pos              // position of NOT keyword
	NotDeferrable      Pos              // position of DEFERRABLE keyword after NOT
	Initially          Pos              // position of INITIALLY keyword
	InitiallyDeferred  Pos              // position of DEFERRED keyword after INITIALLY
	InitiallyImmediate Pos              // position of IMMEDIATE keyword after INITIALLY
}

func (*ForeignKeyConstraint) Clone

Clone returns a deep copy of c.

func (*ForeignKeyConstraint) String

func (c *ForeignKeyConstraint) String() string

String returns the string representation of the constraint.

type FrameSpec

type FrameSpec struct {
	Range  Pos // position of RANGE keyword
	Rows   Pos // position of ROWS keyword
	Groups Pos // position of GROUPS keyword

	Between Pos // position of BETWEEN keyword

	X           Expr // lhs expression
	UnboundedX  Pos  // position of lhs UNBOUNDED keyword
	PrecedingX  Pos  // position of lhs PRECEDING keyword
	CurrentX    Pos  // position of lhs CURRENT keyword
	CurrentRowX Pos  // position of lhs ROW keyword
	FollowingX  Pos  // position of lhs FOLLOWING keyword

	And Pos // position of AND keyword

	Y           Expr // lhs expression
	UnboundedY  Pos  // position of rhs UNBOUNDED keyword
	FollowingY  Pos  // position of rhs FOLLOWING keyword
	CurrentY    Pos  // position of rhs CURRENT keyword
	CurrentRowY Pos  // position of rhs ROW keyword
	PrecedingY  Pos  // position of rhs PRECEDING keyword

	Exclude           Pos // position of EXCLUDE keyword
	ExcludeNo         Pos // position of NO keyword after EXCLUDE
	ExcludeNoOthers   Pos // position of OTHERS keyword after EXCLUDE NO
	ExcludeCurrent    Pos // position of CURRENT keyword after EXCLUDE
	ExcludeCurrentRow Pos // position of ROW keyword after EXCLUDE CURRENT
	ExcludeGroup      Pos // position of GROUP keyword after EXCLUDE
	ExcludeTies       Pos // position of TIES keyword after EXCLUDE
}

func (*FrameSpec) Clone

func (s *FrameSpec) Clone() *FrameSpec

Clone returns a deep copy of s.

func (*FrameSpec) String

func (s *FrameSpec) String() string

String returns the string representation of the frame spec.

type Ident

type Ident struct {
	NamePos Pos    // identifier position
	Name    string // identifier name
	Quoted  bool   // true if double quoted
}

func (*Ident) Clone

func (i *Ident) Clone() *Ident

Clone returns a deep copy of i.

func (*Ident) DataType

func (expr *Ident) DataType() ExprDataType

func (*Ident) IsLiteral

func (expr *Ident) IsLiteral() bool

func (*Ident) Pos

func (expr *Ident) Pos() Pos

func (*Ident) String

func (i *Ident) String() string

String returns the string representation of the expression.

type IndexedColumn

type IndexedColumn struct {
	X    Expr // column expression
	Asc  Pos  // position of optional ASC keyword
	Desc Pos  // position of optional DESC keyword
}

func (*IndexedColumn) Clone

func (c *IndexedColumn) Clone() *IndexedColumn

Clone returns a deep copy of c.

func (*IndexedColumn) String

func (c *IndexedColumn) String() string

String returns the string representation of the column.

type InsertStatement

type InsertStatement struct {
	Insert          Pos // position of INSERT keyword
	Replace         Pos // position of REPLACE keyword
	InsertOr        Pos // position of OR keyword after INSERT
	InsertOrReplace Pos // position of REPLACE keyword after INSERT OR
	//	InsertOrRollback Pos // position of ROLLBACK keyword after INSERT OR
	//	InsertOrAbort    Pos // position of ABORT keyword after INSERT OR
	//	InsertOrFail     Pos // position of FAIL keyword after INSERT OR
	//	InsertOrIgnore   Pos // position of IGNORE keyword after INSERT OR
	Into Pos // position of INTO keyword

	Table *Ident // table name
	As    Pos    // position of AS keyword
	Alias *Ident // optional alias

	ColumnsLparen Pos      // position of column list left paren
	Columns       []*Ident // optional column list
	ColumnsRparen Pos      // position of column list right paren

	Values    Pos         // position of VALUES keyword
	TupleList []*ExprList // multiple tuples

}

func (*InsertStatement) Clone

func (s *InsertStatement) Clone() *InsertStatement

Clone returns a deep copy of s.

func (*InsertStatement) String

func (s *InsertStatement) String() string

type IntegerLit

type IntegerLit struct {
	ValuePos Pos    // literal position
	Value    string // literal value
}

func (*IntegerLit) Clone

func (lit *IntegerLit) Clone() *IntegerLit

Clone returns a deep copy of lit.

func (*IntegerLit) DataType

func (expr *IntegerLit) DataType() ExprDataType

func (*IntegerLit) IsLiteral

func (expr *IntegerLit) IsLiteral() bool

func (*IntegerLit) Pos

func (expr *IntegerLit) Pos() Pos

func (*IntegerLit) String

func (lit *IntegerLit) String() string

String returns the string representation of the expression.

type JoinClause

type JoinClause struct {
	X          Source         // lhs source
	Operator   *JoinOperator  // join operator
	Y          Source         // rhs source
	Constraint JoinConstraint // join constraint
}

func (*JoinClause) Clone

func (c *JoinClause) Clone() *JoinClause

Clone returns a deep copy of c.

func (*JoinClause) OutputColumnNamed

func (c *JoinClause) OutputColumnNamed(name string) (*SourceOutputColumn, error)

func (*JoinClause) OutputColumnQualifierNamed

func (c *JoinClause) OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)

func (*JoinClause) PossibleOutputColumns

func (c *JoinClause) PossibleOutputColumns() []*SourceOutputColumn

func (*JoinClause) SourceFromAlias

func (c *JoinClause) SourceFromAlias(alias string) Source

func (*JoinClause) String

func (c *JoinClause) String() string

String returns the string representation of the clause.

type JoinConstraint

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

JoinConstraint represents either an ON or USING join constraint.

func CloneJoinConstraint

func CloneJoinConstraint(cons JoinConstraint) JoinConstraint

CloneJoinConstraint returns a deep copy cons.

type JoinOperator

type JoinOperator struct {
	Comma Pos // position of comma
	Left  Pos // position of LEFT keyword
	Right Pos // position of RIGHT keyword
	Full  Pos // position of FULL keyword
	Outer Pos // position of OUTER keyword
	Inner Pos // position of INNER keyword
	//	Cross   Pos // position of CROSS keyword // TODO(pok) - add cross back when we do it
	Join Pos // position of JOIN keyword
}

func (*JoinOperator) Clone

func (op *JoinOperator) Clone() *JoinOperator

Clone returns a deep copy of op.

func (*JoinOperator) String

func (op *JoinOperator) String() string

String returns the string representation of the operator.

type KeyPartitionsOption

type KeyPartitionsOption struct {
	KeyPartitions Pos  // position of KEYPARTITIONS keyword
	Expr          Expr // expression
}

func (*KeyPartitionsOption) Clone added in v3.32.0

func (*KeyPartitionsOption) String

func (o *KeyPartitionsOption) String() string

type MaxConstraint

type MaxConstraint struct {
	Max  Pos  // position of MAX keyword
	Expr Expr // check expression
}

func (*MaxConstraint) Clone

func (c *MaxConstraint) Clone() *MaxConstraint

Clone returns a deep copy of c.

func (*MaxConstraint) String

func (c *MaxConstraint) String() string

String returns the string representation of the constraint.

type MinConstraint

type MinConstraint struct {
	Min  Pos  // position of MIN keyword
	Expr Expr // min expression
}

func (*MinConstraint) Clone

func (c *MinConstraint) Clone() *MinConstraint

Clone returns a deep copy of c.

func (*MinConstraint) String

func (c *MinConstraint) String() string

String returns the string representation of the constraint.

type Node

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

func Walk

func Walk(v Visitor, node 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).

type NotNullConstraint

type NotNullConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name
	Not        Pos    // position of NOT keyword
	Null       Pos    // position of NULL keyword
}

func (*NotNullConstraint) Clone

Clone returns a deep copy of c.

func (*NotNullConstraint) String

func (c *NotNullConstraint) String() string

String returns the string representation of the constraint.

type NullLit

type NullLit struct {
	ValuePos Pos
}

func (*NullLit) Clone

func (lit *NullLit) Clone() *NullLit

Clone returns a deep copy of lit.

func (*NullLit) DataType

func (expr *NullLit) DataType() ExprDataType

func (*NullLit) IsLiteral

func (expr *NullLit) IsLiteral() bool

func (*NullLit) Pos

func (expr *NullLit) Pos() Pos

func (*NullLit) String

func (lit *NullLit) String() string

String returns the string representation of the expression.

type OnConstraint

type OnConstraint struct {
	On Pos  // position of ON keyword
	X  Expr // constraint expression
}

func (*OnConstraint) Clone

func (c *OnConstraint) Clone() *OnConstraint

Clone returns a deep copy of c.

func (*OnConstraint) String

func (c *OnConstraint) String() string

String returns the string representation of the constraint.

type OrderingTerm

type OrderingTerm struct {
	X Expr // ordering expression

	Asc  Pos // position of ASC keyword
	Desc Pos // position of DESC keyword

	Nulls      Pos // position of NULLS keyword
	NullsFirst Pos // position of FIRST keyword
	NullsLast  Pos // position of LAST keyword
}

func (*OrderingTerm) Clone

func (t *OrderingTerm) Clone() *OrderingTerm

Clone returns a deep copy of t.

func (*OrderingTerm) String

func (t *OrderingTerm) String() string

String returns the string representation of the term.

type OverClause

type OverClause struct {
	Over       Pos               // position of OVER keyword
	Name       *Ident            // window name
	Definition *WindowDefinition // window definition
}

func (*OverClause) Clone

func (c *OverClause) Clone() *OverClause

Clone returns a deep copy of c.

func (*OverClause) String

func (c *OverClause) String() string

String returns the string representation of the clause.

type ParameterDefinition

type ParameterDefinition struct {
	Name *Variable // parameter name
	Type *Type     // data type
}

type ParenExpr

type ParenExpr struct {
	Lparen Pos  // position of left paren
	X      Expr // parenthesized expression
	Rparen Pos  // position of right paren
}

func (*ParenExpr) Clone

func (expr *ParenExpr) Clone() *ParenExpr

Clone returns a deep copy of expr.

func (*ParenExpr) DataType

func (expr *ParenExpr) DataType() ExprDataType

func (*ParenExpr) IsLiteral

func (expr *ParenExpr) IsLiteral() bool

func (*ParenExpr) Pos

func (expr *ParenExpr) Pos() Pos

func (*ParenExpr) String

func (expr *ParenExpr) String() string

String returns the string representation of the expression.

type ParenSource

type ParenSource struct {
	Lparen Pos    // position of left paren
	X      Source // nested source
	Rparen Pos    // position of right paren
	As     Pos    // position of AS keyword (select source only)
	Alias  *Ident // optional table alias (select source only)
}

func (*ParenSource) Clone

func (s *ParenSource) Clone() *ParenSource

Clone returns a deep copy of s.

func (*ParenSource) OutputColumnNamed

func (c *ParenSource) OutputColumnNamed(name string) (*SourceOutputColumn, error)

func (*ParenSource) OutputColumnQualifierNamed

func (c *ParenSource) OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)

func (*ParenSource) PossibleOutputColumns

func (c *ParenSource) PossibleOutputColumns() []*SourceOutputColumn

func (*ParenSource) SourceFromAlias

func (c *ParenSource) SourceFromAlias(alias string) Source

func (*ParenSource) String

func (s *ParenSource) String() string

String returns the string representation of the source.

type Parser

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

Parser represents a SQL parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser that reads from r.

func (*Parser) ParseExpr

func (p *Parser) ParseExpr() (expr Expr, err error)

func (*Parser) ParseStatement

func (p *Parser) ParseStatement() (stmt Statement, err error)

type Pos

type Pos struct {
	Offset int // offset, starting at 0
	Line   int // line number, starting at 1
	Column int // column number, starting at 1 (byte count)
}

func (Pos) IsValid

func (p Pos) IsValid() bool

IsValid returns true if p is non-zero.

func (Pos) String

func (p Pos) String() string

String returns a string representation of the position.

type PrimaryKeyConstraint

type PrimaryKeyConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name
	Primary    Pos    // position of PRIMARY keyword
	Key        Pos    // position of KEY keyword

	Lparen  Pos      // position of left paren (table only)
	Columns []*Ident // indexed columns (table only)
	Rparen  Pos      // position of right paren (table only)

	Autoincrement Pos // position of AUTOINCREMENT keyword (column only)
}

func (*PrimaryKeyConstraint) Clone

Clone returns a deep copy of c.

func (*PrimaryKeyConstraint) String

func (c *PrimaryKeyConstraint) String() string

String returns the string representation of the constraint.

type QualifiedRef

type QualifiedRef struct {
	Table       *Ident // table name
	Dot         Pos    // position of dot
	Star        Pos    // position of * (result column only)
	Column      *Ident // column name
	ColumnIndex int

	// Set by the planner; not at parse-time
	RefDataType ExprDataType
}

func (*QualifiedRef) Clone

func (r *QualifiedRef) Clone() *QualifiedRef

Clone returns a deep copy of r.

func (*QualifiedRef) DataType

func (expr *QualifiedRef) DataType() ExprDataType

func (*QualifiedRef) IsLiteral

func (expr *QualifiedRef) IsLiteral() bool

func (*QualifiedRef) Pos

func (expr *QualifiedRef) Pos() Pos

func (*QualifiedRef) String

func (r *QualifiedRef) String() string

String returns the string representation of the expression.

type QualifiedTableName

type QualifiedTableName struct {
	Name          *Ident                // table name
	As            Pos                   // position of AS keyword
	Alias         *Ident                // optional table alias
	Indexed       Pos                   // position of INDEXED keyword
	IndexedBy     Pos                   // position of BY keyword after INDEXED
	Not           Pos                   // position of NOT keyword before INDEXED
	NotIndexed    Pos                   // position of NOT keyword before INDEXED
	Index         *Ident                // name of index
	OutputColumns []*SourceOutputColumn // output columns - populated during analysis
}

func (*QualifiedTableName) Clone

Clone returns a deep copy of n.

func (*QualifiedTableName) MatchesTablenameOrAlias

func (n *QualifiedTableName) MatchesTablenameOrAlias(match string) bool

func (*QualifiedTableName) OutputColumnNamed

func (c *QualifiedTableName) OutputColumnNamed(name string) (*SourceOutputColumn, error)

func (*QualifiedTableName) OutputColumnQualifierNamed

func (c *QualifiedTableName) OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)

func (*QualifiedTableName) PossibleOutputColumns

func (c *QualifiedTableName) PossibleOutputColumns() []*SourceOutputColumn

func (*QualifiedTableName) SourceFromAlias

func (c *QualifiedTableName) SourceFromAlias(alias string) Source

func (*QualifiedTableName) String

func (n *QualifiedTableName) String() string

String returns the string representation of the table name.

func (*QualifiedTableName) TableName

func (n *QualifiedTableName) TableName() string

TableName returns the name used to identify n. Returns the alias, if one is specified. Otherwise returns the name.

type Range

type Range struct {
	X   Expr // lhs expression
	And Pos  // position of AND keyword
	Y   Expr // rhs expression

	ResultDataType ExprDataType
}

func (*Range) Clone

func (r *Range) Clone() *Range

Clone returns a deep copy of r.

func (*Range) DataType

func (expr *Range) DataType() ExprDataType

func (*Range) IsLiteral

func (expr *Range) IsLiteral() bool

func (*Range) Pos

func (expr *Range) Pos() Pos

func (*Range) String

func (r *Range) String() string

String returns the string representation of the expression.

type ReleaseStatement

type ReleaseStatement struct {
	Release   Pos    // position of RELEASE keyword
	Savepoint Pos    // position of SAVEPOINT keyword (optional)
	Name      *Ident // name of savepoint
}

func (*ReleaseStatement) Clone

func (s *ReleaseStatement) Clone() *ReleaseStatement

Clone returns a deep copy of s.

func (*ReleaseStatement) String

func (s *ReleaseStatement) String() string

String returns the string representation of the statement.

type ResultColumn

type ResultColumn struct {
	Star  Pos    // position of *
	Expr  Expr   // column expression (may be "tbl.*")
	As    Pos    // position of AS keyword
	Alias *Ident // alias name
}

func (*ResultColumn) Clone

func (c *ResultColumn) Clone() *ResultColumn

Clone returns a deep copy of c.

func (*ResultColumn) IsLiteral

func (expr *ResultColumn) IsLiteral() bool

func (*ResultColumn) Name

func (c *ResultColumn) Name() string

Name returns the column name. Uses the alias, if specified. Otherwise returns a generated name.

func (*ResultColumn) String

func (c *ResultColumn) String() string

String returns the string representation of the column.

type RollbackStatement

type RollbackStatement struct {
	Rollback      Pos    // position of ROLLBACK keyword
	Transaction   Pos    // position of TRANSACTION keyword  (optional)
	To            Pos    // position of TO keyword  (optional)
	Savepoint     Pos    // position of SAVEPOINT keyword  (optional)
	SavepointName *Ident // name of savepoint
}

func (*RollbackStatement) Clone

Clone returns a deep copy of s.

func (*RollbackStatement) String

func (s *RollbackStatement) String() string

String returns the string representation of the statement.

type SavepointStatement

type SavepointStatement struct {
	Savepoint Pos    // position of SAVEPOINT keyword
	Name      *Ident // name of savepoint
}

func (*SavepointStatement) Clone

Clone returns a deep copy of s.

func (*SavepointStatement) String

func (s *SavepointStatement) String() string

String returns the string representation of the statement.

type Scanner

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

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (pos Pos, token Token, lit string)

type SelectStatement

type SelectStatement struct {
	WithClause *WithClause // clause containing CTEs

	Select   Pos // position of SELECT keyword
	Distinct Pos // position of DISTINCT keyword
	//	All      Pos             // position of ALL keyword
	Columns []*ResultColumn // list of result columns in the SELECT clause

	Top     Pos  // position of TOP keyword
	TopN    Pos  // position of TOPN keyword
	TopExpr Expr // TOP expr

	From   Pos    // position of FROM keyword
	Source Source // chain of tables & subqueries in FROM clause

	Where     Pos  // position of WHERE keyword
	WhereExpr Expr // condition for WHERE clause

	Group        Pos    // position of GROUP keyword
	GroupBy      Pos    // position of BY keyword after GROUP
	GroupByExprs []Expr // group by expression list
	Having       Pos    // position of HAVING keyword
	HavingExpr   Expr   // HAVING expression

	Window  Pos       // position of WINDOW keyword
	Windows []*Window // window list

	Union     Pos              // position of UNION keyword
	UnionAll  Pos              // position of ALL keyword after UNION
	Intersect Pos              // position of INTERSECT keyword
	Except    Pos              // position of EXCEPT keyword
	Compound  *SelectStatement // compounded SELECT statement

	Order         Pos             // position of ORDER keyword
	OrderBy       Pos             // position of BY keyword after ORDER
	OrderingTerms []*OrderingTerm // terms of ORDER BY clause

}

func (*SelectStatement) Clone

func (s *SelectStatement) Clone() *SelectStatement

Clone returns a deep copy of s.

func (*SelectStatement) DataType

func (s *SelectStatement) DataType() ExprDataType

func (*SelectStatement) HasWildcard

func (s *SelectStatement) HasWildcard() bool

HasWildcard returns true any result column contains a wildcard (STAR).

func (*SelectStatement) IsLiteral

func (expr *SelectStatement) IsLiteral() bool

func (*SelectStatement) OutputColumnNamed

func (c *SelectStatement) OutputColumnNamed(name string) (*SourceOutputColumn, error)

func (*SelectStatement) OutputColumnQualifierNamed

func (c *SelectStatement) OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)

func (*SelectStatement) Pos

func (s *SelectStatement) Pos() Pos

func (*SelectStatement) PossibleOutputColumns

func (c *SelectStatement) PossibleOutputColumns() []*SourceOutputColumn

func (*SelectStatement) SourceFromAlias

func (c *SelectStatement) SourceFromAlias(alias string) Source

func (*SelectStatement) String

func (s *SelectStatement) String() string

String returns the string representation of the statement.

type SetLiteralExpr

type SetLiteralExpr struct {
	Lbracket Pos    // position of left bracket
	Members  []Expr // bracketed expression
	Rbracket Pos    // position of right bracket

	ResultDataType ExprDataType
}

func (*SetLiteralExpr) Clone

func (expr *SetLiteralExpr) Clone() *SetLiteralExpr

Clone returns a deep copy of expr.

func (*SetLiteralExpr) DataType

func (expr *SetLiteralExpr) DataType() ExprDataType

func (*SetLiteralExpr) IsLiteral

func (expr *SetLiteralExpr) IsLiteral() bool

func (*SetLiteralExpr) Pos

func (expr *SetLiteralExpr) Pos() Pos

func (*SetLiteralExpr) String

func (expr *SetLiteralExpr) String() string

String returns the string representation of the expression.

type ShowColumnsStatement

type ShowColumnsStatement struct {
	Show      Pos    // position of SHOW
	Columns   Pos    // position of COLUMNS
	From      Pos    // position of FROM
	TableName *Ident // name of table
}

func (*ShowColumnsStatement) Clone added in v3.32.0

func (*ShowColumnsStatement) String

func (s *ShowColumnsStatement) String() string

String returns the string representation of the statement.

type ShowCreateTableStatement

type ShowCreateTableStatement struct {
	Show      Pos    // position of SHOW
	Create    Pos    // position of CREATE
	Table     Pos    // position of CREATE
	TableName *Ident // name of table
}

func (*ShowCreateTableStatement) Clone added in v3.32.0

func (*ShowCreateTableStatement) String

func (s *ShowCreateTableStatement) String() string

String returns the string representation of the statement.

type ShowDatabasesStatement added in v3.32.0

type ShowDatabasesStatement struct {
	Show      Pos // position of SHOW
	Databases Pos // position of DATABASES
}

func (*ShowDatabasesStatement) Clone added in v3.32.0

String returns the string representation of the statement.

func (*ShowDatabasesStatement) String added in v3.32.0

func (s *ShowDatabasesStatement) String() string

String returns the string representation of the statement.

type ShowTablesStatement

type ShowTablesStatement struct {
	Show   Pos // position of SHOW
	Tables Pos // position of TABLES
}

func (*ShowTablesStatement) Clone added in v3.32.0

func (*ShowTablesStatement) String

func (s *ShowTablesStatement) String() string

String returns the string representation of the statement.

type Source

type Source interface {
	Node

	SourceFromAlias(alias string) Source

	// get the possible output columns from the source
	PossibleOutputColumns() []*SourceOutputColumn

	// find output columns by name
	OutputColumnNamed(name string) (*SourceOutputColumn, error)
	OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)
	// contains filtered or unexported methods
}

Source represents a data source for a select statement. A select statement has one source, but they can be one of a table ref, a join, another select statement or any of the above parenthesiszed. For join operators, the Source can form a graph, with the join terms being themselves a Source.

func CloneSource

func CloneSource(src Source) Source

CloneSource returns a deep copy src.

func SourceList

func SourceList(src Source) []Source

SourceList returns a list of sources starting from a source.

func StatementSource

func StatementSource(stmt Statement) Source

StatementSource returns the root statement for a statement.

type SourceOutputColumn

type SourceOutputColumn struct {
	TableName   string
	ColumnName  string
	ColumnIndex int
	Datatype    ExprDataType
}

SourceOutputColumn is an identifier that is either a possible output column for a Source or a referenced output column for a Source. These are computed during the analysis phase

type Statement

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

func CloneStatement

func CloneStatement(stmt Statement) Statement

CloneStatement returns a deep copy stmt.

type StringLit

type StringLit struct {
	ValuePos Pos    // literal position
	Value    string // literal value (without quotes)
	IsBlob   bool   // are we a blob?
}

func (*StringLit) Clone

func (lit *StringLit) Clone() *StringLit

Clone returns a deep copy of lit.

func (*StringLit) ConvertToTimestamp

func (expr *StringLit) ConvertToTimestamp() *DateLit

func (*StringLit) DataType

func (expr *StringLit) DataType() ExprDataType

func (*StringLit) IsLiteral

func (expr *StringLit) IsLiteral() bool

func (*StringLit) Pos

func (expr *StringLit) Pos() Pos

func (*StringLit) String

func (lit *StringLit) String() string

String returns the string representation of the expression.

type SubtableColumn

type SubtableColumn struct {
	Name     string
	DataType ExprDataType
}

type SysVariable added in v3.35.0

type SysVariable struct {
	NamePos Pos   // variable position in sql
	Token   Token // parser token mapped to the variable's name/keyword
}

SysVariable represents built-in system variables that can be referenced in the sql for current date, current time and other potential pre-determinable values. In SQL these system provided data elements are referenced using keywords such as CURRENT_DATE & CURRENT_TIMESTAMP, etc.

func (*SysVariable) Clone added in v3.35.0

func (svar *SysVariable) Clone() *SysVariable

func (*SysVariable) DataType added in v3.35.0

func (svar *SysVariable) DataType() ExprDataType

func (*SysVariable) IsLiteral added in v3.35.0

func (*SysVariable) IsLiteral() bool

func (*SysVariable) Name added in v3.35.0

func (svar *SysVariable) Name() string

func (*SysVariable) Pos added in v3.35.0

func (svar *SysVariable) Pos() Pos

func (*SysVariable) String added in v3.35.0

func (svar *SysVariable) String() string

type TableOption

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

func CloneTableOption added in v3.32.0

func CloneTableOption(opt TableOption) TableOption

type TableValuedFunction

type TableValuedFunction struct {
	Name          *Ident                // table name
	As            Pos                   // position of AS keyword
	Alias         *Ident                // optional table alias
	Call          *Call                 // call
	OutputColumns []*SourceOutputColumn // output columns - populated during analysis
}

func (*TableValuedFunction) Clone

Clone returns a deep copy of n.

func (*TableValuedFunction) MatchesTablenameOrAlias

func (n *TableValuedFunction) MatchesTablenameOrAlias(match string) bool

func (*TableValuedFunction) OutputColumnNamed

func (c *TableValuedFunction) OutputColumnNamed(name string) (*SourceOutputColumn, error)

func (*TableValuedFunction) OutputColumnQualifierNamed

func (c *TableValuedFunction) OutputColumnQualifierNamed(qualifier string, name string) (*SourceOutputColumn, error)

func (*TableValuedFunction) PossibleOutputColumns

func (c *TableValuedFunction) PossibleOutputColumns() []*SourceOutputColumn

func (*TableValuedFunction) SourceFromAlias

func (c *TableValuedFunction) SourceFromAlias(alias string) Source

func (*TableValuedFunction) String

func (n *TableValuedFunction) String() string

String returns the string representation of the table name.

func (*TableValuedFunction) TableName

func (n *TableValuedFunction) TableName() string

TableName returns the name used to identify n. Returns the alias, if one is specified. Otherwise returns the name.

type TimeQuantumConstraint

type TimeQuantumConstraint struct {
	TimeQuantum Pos  // position of TIMEQUANTUM keyword
	Expr        Expr // expression
	Ttl         Pos
	TtlExpr     Expr
}

func (*TimeQuantumConstraint) Clone

Clone returns a deep copy of c.

func (*TimeQuantumConstraint) String

func (c *TimeQuantumConstraint) String() string

String returns the string representation of the constraint.

type TimeUnitConstraint

type TimeUnitConstraint struct {
	TimeUnit  Pos  // position of TIMEUNIT keyword
	Expr      Expr // expression
	Epoch     Pos  // position of TIMEUNIT keyword
	EpochExpr Expr // expression
}

func (*TimeUnitConstraint) Clone

Clone returns a deep copy of c.

func (*TimeUnitConstraint) String

func (c *TimeUnitConstraint) String() string

String returns the string representation of the constraint.

type Token

type Token int

Token is the set of lexical tokens of the Go programming language.

const (
	// Special tokens
	ILLEGAL Token = iota
	EOF
	SPACE
	UNTERMSTRING

	IDENT    // IDENT
	VARIABLE // VARIABLE
	QIDENT   // "IDENT"
	STRING   // 'string'
	BLOB     // X'data'
	FLOAT    // 123.45
	INTEGER  // 123
	NULL     // NULL
	TRUE     // true
	FALSE    // false

	SEMI   // ;
	LP     // (
	RP     // )
	LB     // [
	RB     // ]
	LBR    // {
	RBR    // }
	COMMA  // ,
	NE     // !=
	EQ     // =
	LE     // <=
	LT     // <
	GT     // >
	GE     // >=
	BITAND // &
	BITOR  // |
	BITNOT // !
	LSHIFT // <<
	RSHIFT // >>
	PLUS   // +
	MINUS  // -
	STAR   // *
	SLASH  // /
	REM    // %
	CONCAT // ||
	DOT    // .

	ABORT
	ACTION
	ADD
	AFTER
	AGG_COLUMN
	AGG_FUNCTION
	ALL
	ALTER
	ANALYZE
	AND
	AS
	ASC
	ASTERISK
	ATTACH
	AUTOINCREMENT
	BEFORE
	BEGIN
	BETWEEN
	BY
	BULK
	CACHETYPE
	CASCADE
	CASE
	CAST
	CHECK
	COLUMN
	COLUMNS
	COLUMNKW
	COMMIT
	COMMENT
	CONFLICT
	CONSTRAINT
	CREATE
	CROSS
	CTIME_KW
	CURRENT
	CURRENT_DATE
	CURRENT_TIMESTAMP
	DATABASE
	DATABASES
	DEFAULT
	DEFERRABLE
	DEFERRED
	DELETE
	DESC
	DETACH
	DISTINCT
	DO
	DROP
	EACH
	ELSE
	END
	EPOCH
	ESCAPE
	EXCEPT
	EXCLUDE
	EXCLUSIVE
	EXISTS
	EXPLAIN
	FAIL
	FILTER
	FIRST
	FOLLOWING
	FOR
	FOREIGN
	FROM
	FULL
	FUNCTION
	GLOB
	GROUP
	GROUPS
	HAVING
	IF
	IF_NULL_ROW
	IGNORE
	IMMEDIATE
	IN
	INDEX
	INDEXED
	INITIALLY
	INNER
	INSERT
	INSTEAD
	INTERSECT
	INTO
	IS
	ISNOT
	JOIN
	KEY
	KEYPARTITIONS
	LAST
	LEFT
	LIKE
	LRU
	MAP
	MATCH
	MAX
	MIN
	NO
	NOT
	NOTBETWEEN
	NOTEXISTS
	NOTGLOB
	NOTHING
	NOTIN
	NOTLIKE
	NOTMATCH
	NOTREGEXP
	NULLS
	OF
	ON
	OR
	ORDER
	OTHERS
	OUTER
	OVER
	PARTITION
	PLAN
	PRAGMA
	PRECEDING
	PRIMARY
	QUERY
	RANGE
	RANKED
	RECURSIVE
	REFERENCES
	REGEXP
	REGISTER
	REINDEX
	RELEASE
	RENAME
	REPLACE
	RESTRICT
	RETURNS
	RETURN
	RIGHT
	ROLLBACK
	ROW
	ROWS
	SAVEPOINT
	SELECT
	SELECT_COLUMN
	SET
	SIZE
	SHOW
	SPAN
	TABLE
	TABLES
	TEMP
	THEN
	TIES
	TIMEUNIT
	TIMEQUANTUM
	TO
	TOP
	TOPN
	TRANSACTION
	TRANSFORM
	TRIGGER
	TRUTH
	TTL
	UNBOUNDED
	UNION
	UNIQUE
	UNITS
	UPDATE
	USING
	VACUUM
	VALUES
	VECTOR
	VIEW
	VIRTUAL
	WHEN
	WHERE
	WINDOW
	WITH
	WITHOUT

	ANY // ???
)

TODO (pok) remove unnecessary tokens The list of tokens.

func Lookup

func Lookup(ident string) Token

func (Token) IsBinaryOp

func (tok Token) IsBinaryOp() bool

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

func (Token) IsOperator

func (tok Token) IsOperator() bool

func (Token) Precedence

func (op Token) Precedence() int

func (Token) String

func (tok Token) String() string

type TupleLiteralExpr

type TupleLiteralExpr struct {
	Lbrace  Pos    // position of left brace
	Members []Expr // bracketed expression
	Rbrace  Pos    // position of right brace

	ResultDataType ExprDataType
}

func (*TupleLiteralExpr) Clone

func (expr *TupleLiteralExpr) Clone() *TupleLiteralExpr

Clone returns a deep copy of expr.

func (*TupleLiteralExpr) DataType

func (expr *TupleLiteralExpr) DataType() ExprDataType

func (*TupleLiteralExpr) IsLiteral

func (expr *TupleLiteralExpr) IsLiteral() bool

func (*TupleLiteralExpr) Pos

func (expr *TupleLiteralExpr) Pos() Pos

func (*TupleLiteralExpr) String

func (expr *TupleLiteralExpr) String() string

String returns the string representation of the expression.

type Type

type Type struct {
	Name      *Ident      // type name
	Lparen    Pos         // position of left paren (optional)
	Precision *IntegerLit // precision (optional)
	Scale     *IntegerLit // scale (optional)
	Rparen    Pos         // position of right paren (optional)
}

func (*Type) Clone

func (t *Type) Clone() *Type

Clone returns a deep copy of t.

func (*Type) String

func (t *Type) String() string

String returns the string representation of the type.

type UnaryExpr

type UnaryExpr struct {
	OpPos Pos   // operation position
	Op    Token // operation
	X     Expr  // target expression

	ResultDataType ExprDataType
}

func (*UnaryExpr) Clone

func (expr *UnaryExpr) Clone() *UnaryExpr

Clone returns a deep copy of expr.

func (*UnaryExpr) DataType

func (expr *UnaryExpr) DataType() ExprDataType

func (*UnaryExpr) IsLiteral

func (expr *UnaryExpr) IsLiteral() bool

func (*UnaryExpr) Pos

func (expr *UnaryExpr) Pos() Pos

func (*UnaryExpr) String

func (expr *UnaryExpr) String() string

String returns the string representation of the expression.

type UniqueConstraint

type UniqueConstraint struct {
	Constraint Pos    // position of CONSTRAINT keyword
	Name       *Ident // constraint name
	Unique     Pos    // position of UNIQUE keyword

	Lparen  Pos      // position of left paren (table only)
	Columns []*Ident // indexed columns (table only)
	Rparen  Pos      // position of right paren (table only)
}

func (*UniqueConstraint) Clone

func (c *UniqueConstraint) Clone() *UniqueConstraint

Clone returns a deep copy of c.

func (*UniqueConstraint) String

func (c *UniqueConstraint) String() string

String returns the string representation of the constraint.

type UnitsOption added in v3.32.0

type UnitsOption struct {
	Units Pos  // position of UNITS keyword
	Expr  Expr // expression
}

func (*UnitsOption) String added in v3.32.0

func (o *UnitsOption) String() string

type UpdateStatement

type UpdateStatement struct {
	WithClause *WithClause // clause containing CTEs

	Update           Pos // position of UPDATE keyword
	UpdateOr         Pos // position of OR keyword after UPDATE
	UpdateOrReplace  Pos // position of REPLACE keyword after UPDATE OR
	UpdateOrRollback Pos // position of ROLLBACK keyword after UPDATE OR
	UpdateOrAbort    Pos // position of ABORT keyword after UPDATE OR
	UpdateOrFail     Pos // position of FAIL keyword after UPDATE OR
	UpdateOrIgnore   Pos // position of IGNORE keyword after UPDATE OR

	Table *QualifiedTableName // table name

	Set         Pos           // position of SET keyword
	Assignments []*Assignment // list of column assignments
	Where       Pos           // position of WHERE keyword
	WhereExpr   Expr          // conditional expression
}

func (*UpdateStatement) Clone

func (s *UpdateStatement) Clone() *UpdateStatement

Clone returns a deep copy of s.

func (*UpdateStatement) String

func (s *UpdateStatement) String() string

String returns the string representation of the clause.

type UpsertClause

type UpsertClause struct {
	On         Pos // position of ON keyword
	OnConflict Pos // position of CONFLICT keyword after ON

	Lparen    Pos              // position of column list left paren
	Columns   []*IndexedColumn // optional indexed column list
	Rparen    Pos              // position of column list right paren
	Where     Pos              // position of WHERE keyword
	WhereExpr Expr             // optional conditional expression

	Do              Pos           // position of DO keyword
	DoNothing       Pos           // position of NOTHING keyword after DO
	DoUpdate        Pos           // position of UPDATE keyword after DO
	DoUpdateSet     Pos           // position of SET keyword after DO UPDATE
	Assignments     []*Assignment // list of column assignments
	UpdateWhere     Pos           // position of WHERE keyword for DO UPDATE SET
	UpdateWhereExpr Expr          // optional conditional expression for DO UPDATE SET
}

func (*UpsertClause) Clone

func (c *UpsertClause) Clone() *UpsertClause

Clone returns a deep copy of c.

func (*UpsertClause) String

func (c *UpsertClause) String() string

String returns the string representation of the clause.

type UsingConstraint

type UsingConstraint struct {
	Using   Pos      // position of USING keyword
	Lparen  Pos      // position of left paren
	Columns []*Ident // column list
	Rparen  Pos      // position of right paren
}

func (*UsingConstraint) Clone

func (c *UsingConstraint) Clone() *UsingConstraint

Clone returns a deep copy of c.

func (*UsingConstraint) String

func (c *UsingConstraint) String() string

String returns the string representation of the constraint.

type Variable

type Variable struct {
	NamePos       Pos    // variable position
	Name          string // variable name
	VariableIndex int
	VarDataType   ExprDataType
}

func (*Variable) Clone

func (i *Variable) Clone() *Variable

Clone returns a deep copy of i.

func (*Variable) DataType

func (expr *Variable) DataType() ExprDataType

func (*Variable) IsLiteral

func (expr *Variable) IsLiteral() bool

func (*Variable) Pos

func (expr *Variable) Pos() Pos

func (*Variable) String

func (i *Variable) String() string

String returns the string representation of the expression.

func (*Variable) VarName

func (i *Variable) VarName() string

type VisitEndFunc

type VisitEndFunc func(Node) (Node, error)

VisitEndFunc represents a function type that implements Visitor. Only executes on node exit.

func (VisitEndFunc) Visit

func (fn VisitEndFunc) Visit(node Node) (Visitor, Node, error)

Visit is a no-op.

func (VisitEndFunc) VisitEnd

func (fn VisitEndFunc) VisitEnd(node Node) (Node, error)

VisitEnd executes fn.

type VisitFunc

type VisitFunc func(Node) (Node, error)

VisitFunc represents a function type that implements Visitor. Only executes on node entry.

func (VisitFunc) Visit

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

Visit executes fn. Walk visits node children if fn returns true.

func (VisitFunc) VisitEnd

func (fn VisitFunc) VisitEnd(node Node) (Node, error)

VisitEnd is a no-op.

type Visitor

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

Visitor is an interface implemented by anything needed to act on nodes walked during a node traversal. A Visitor's Visit method is invoked 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 Window

type Window struct {
	Name       *Ident            // name of window
	As         Pos               // position of AS keyword
	Definition *WindowDefinition // window definition
}

func (*Window) Clone

func (w *Window) Clone() *Window

Clone returns a deep copy of w.

func (*Window) String

func (w *Window) String() string

String returns the string representation of the window.

type WindowDefinition

type WindowDefinition struct {
	Lparen        Pos             // position of left paren
	Base          *Ident          // base window name
	Partition     Pos             // position of PARTITION keyword
	PartitionBy   Pos             // position of BY keyword (after PARTITION)
	Partitions    []Expr          // partition expressions
	Order         Pos             // position of ORDER keyword
	OrderBy       Pos             // position of BY keyword (after ORDER)
	OrderingTerms []*OrderingTerm // ordering terms
	Frame         *FrameSpec      // frame
	Rparen        Pos             // position of right paren
}

func (*WindowDefinition) Clone

func (d *WindowDefinition) Clone() *WindowDefinition

Clone returns a deep copy of d.

func (*WindowDefinition) String

func (d *WindowDefinition) String() string

String returns the string representation of the window definition.

type WithClause

type WithClause struct {
	With      Pos    // position of WITH keyword
	Recursive Pos    // position of RECURSIVE keyword
	CTEs      []*CTE // common table expressions
}

func (*WithClause) Clone

func (c *WithClause) Clone() *WithClause

Clone returns a deep copy of c.

func (*WithClause) String

func (c *WithClause) String() string

String returns the string representation of the clause.

Jump to

Keyboard shortcuts

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