ast

package
v0.0.0-...-959c02d Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ast is the abstract syntax tree parsed from a SQL statement by parser. It can be analysed and transformed by optimizer.

Index

Constants

View Source
const (
	EdgeDirectionOutgoing = iota
	EdgeDirectionIncoming
	EdgeDirectionAnyDirected
)
View Source
const (
	PatternQuantifierZeroOrMore = iota
	PatternQuantifierOneOrMore
	PatternQuantifierOptional
	PatternQuantifierExactlyN
	PatternQuantifierNOrMore
	PatternQuantifierBetweenNAndM
	PatternQuantifierBetweenZeroAndM
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateFuncExpr

type AggregateFuncExpr struct {

	// F is the function name.
	F string
	// Args is the function args.
	Args []ExprNode
	// Distinct is true, function hence only aggregate distinct values.
	// For example, column c1 values are "1", "2", "2",  "sum(c1)" is "5",
	// but "sum(distinct c1)" is "3".
	Distinct bool
	// contains filtered or unexported fields
}

AggregateFuncExpr represents aggregate function expression.

func (*AggregateFuncExpr) Accept

func (n *AggregateFuncExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*AggregateFuncExpr) Restore

func (n *AggregateFuncExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type BeginStmt

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

func (*BeginStmt) Accept

func (b *BeginStmt) Accept(v Visitor) (node Node, ok bool)

func (*BeginStmt) Restore

func (b *BeginStmt) Restore(ctx *format.RestoreCtx) error

type BinaryExpr

type BinaryExpr struct {

	// Op is the operator code for BinaryOperation.
	Op opcode.Op
	// L is the left expression in BinaryOperation.
	L ExprNode
	// R is the right expression in BinaryOperation.
	R ExprNode
	// contains filtered or unexported fields
}

BinaryExpr is for binary operation like `1 + 1`, `1 - 1`, etc.

func (*BinaryExpr) Accept

func (n *BinaryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*BinaryExpr) Restore

func (n *BinaryExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type BindVariable

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

func (*BindVariable) Accept

func (n *BindVariable) Accept(v Visitor) (node Node, ok bool)

func (*BindVariable) Restore

func (n *BindVariable) Restore(ctx *format.RestoreCtx) error

type ByItem

type ByItem struct {
	Expr      *ExpAsVar
	Desc      bool
	NullOrder bool
	// contains filtered or unexported fields
}

ByItem represents an item in order by or group by.

func (*ByItem) Accept

func (n *ByItem) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ByItem) OriginTextPosition

func (n *ByItem) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*ByItem) Restore

func (n *ByItem) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*ByItem) SetOriginTextPosition

func (n *ByItem) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*ByItem) SetText

func (n *ByItem) SetText(text string)

SetText implements Node interface.

func (*ByItem) Text

func (n *ByItem) Text() string

Text implements Node interface.

type CaseExpr

type CaseExpr struct {

	// Value is the compare value expression.
	Value ExprNode
	// WhenClauses is the condition check expression.
	WhenClauses []*WhenClause
	// ElseClause is the else result expression.
	ElseClause ExprNode
	// contains filtered or unexported fields
}

CaseExpr is the case expression.

func (*CaseExpr) Accept

func (n *CaseExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CaseExpr) Restore

func (n *CaseExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type CastFuncExpr

type CastFuncExpr struct {

	// Expr is the expression to be converted.
	Expr ExprNode
	// DataType is the conversion type.
	DataType DataType
	// contains filtered or unexported fields
}

func (*CastFuncExpr) Accept

func (n *CastFuncExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CastFuncExpr) Restore

func (n *CastFuncExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type CommitStmt

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

func (*CommitStmt) Accept

func (c *CommitStmt) Accept(v Visitor) (node Node, ok bool)

func (*CommitStmt) Restore

func (c *CommitStmt) Restore(ctx *format.RestoreCtx) error

type CreateGraphStmt

type CreateGraphStmt struct {
	IfNotExists bool
	Graph       model.CIStr
	// contains filtered or unexported fields
}

func (*CreateGraphStmt) Accept

func (n *CreateGraphStmt) Accept(v Visitor) (Node, bool)

func (*CreateGraphStmt) Restore

func (n *CreateGraphStmt) Restore(ctx *format.RestoreCtx) error

type CreateIndexStmt

type CreateIndexStmt struct {
	KeyType     IndexKeyType
	IfNotExists bool

	IndexName  model.CIStr
	Properties []model.CIStr
	// contains filtered or unexported fields
}

CreateIndexStmt is a statement to create an index. See https://dev.mysql.com/doc/refman/5.7/en/create-index.html

func (*CreateIndexStmt) Accept

func (n *CreateIndexStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CreateIndexStmt) Restore

func (n *CreateIndexStmt) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type CreateLabelStmt

type CreateLabelStmt struct {
	IfNotExists bool
	Label       model.CIStr
	// contains filtered or unexported fields
}

func (*CreateLabelStmt) Accept

func (n *CreateLabelStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CreateLabelStmt) Restore

func (n *CreateLabelStmt) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type DDLNode

type DDLNode interface {
	StmtNode
	// contains filtered or unexported methods
}

DDLNode represents DDL statement node.

type DMLNode

type DMLNode interface {
	StmtNode
	// contains filtered or unexported methods
}

DMLNode represents DML statement node.

type DataType

type DataType uint8
const (
	DataTypeString DataType = iota
	DataTypeBoolean
	DataTypeInteger
	DataTypeFloat
	DataTypeDouble
	DataTypeDecimal
	DataTypeDate
	DataTypeTime
	DataTypeTimeWithTimeZone
	DataTypeTimestamp
	DataTypeTimestampWithTimeZone
)

func (DataType) String

func (f DataType) String() string

type DeleteStmt

type DeleteStmt struct {
	PathPatternMacros []*PathPatternMacro
	VariableNames     []model.CIStr
	From              *MatchClauseList
	Where             ExprNode
	GroupBy           *GroupByClause
	Having            *HavingClause
	OrderBy           *OrderByClause
	Limit             *LimitClause
	// contains filtered or unexported fields
}

func (*DeleteStmt) Accept

func (d *DeleteStmt) Accept(v Visitor) (node Node, ok bool)

func (*DeleteStmt) Restore

func (d *DeleteStmt) Restore(ctx *format.RestoreCtx) error

type DropGraphStmt

type DropGraphStmt struct {
	IfExists bool
	Graph    model.CIStr
	// contains filtered or unexported fields
}

func (*DropGraphStmt) Accept

func (n *DropGraphStmt) Accept(v Visitor) (Node, bool)

func (*DropGraphStmt) Restore

func (n *DropGraphStmt) Restore(ctx *format.RestoreCtx) error

type DropIndexStmt

type DropIndexStmt struct {
	IfExists  bool
	IndexName model.CIStr
	// contains filtered or unexported fields
}

DropIndexStmt is a statement to drop the index. See https://dev.mysql.com/doc/refman/5.7/en/drop-index.html

func (*DropIndexStmt) Accept

func (n *DropIndexStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*DropIndexStmt) Restore

func (n *DropIndexStmt) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type DropLabelStmt

type DropLabelStmt struct {
	IfExists bool
	Label    model.CIStr
	// contains filtered or unexported fields
}

func (*DropLabelStmt) Accept

func (n *DropLabelStmt) Accept(v Visitor) (Node, bool)

func (*DropLabelStmt) Restore

func (n *DropLabelStmt) Restore(ctx *format.RestoreCtx) error

type EdgeDirection

type EdgeDirection int

type EdgePattern

type EdgePattern struct {
	Variable  *VariableSpec
	Direction EdgeDirection
	// contains filtered or unexported fields
}

func (*EdgePattern) Accept

func (n *EdgePattern) Accept(v Visitor) (Node, bool)

func (*EdgePattern) OriginTextPosition

func (n *EdgePattern) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*EdgePattern) Restore

func (n *EdgePattern) Restore(ctx *format.RestoreCtx) error

func (*EdgePattern) SetOriginTextPosition

func (n *EdgePattern) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*EdgePattern) SetText

func (n *EdgePattern) SetText(text string)

SetText implements Node interface.

func (*EdgePattern) Text

func (n *EdgePattern) Text() string

Text implements Node interface.

type ExistsSubqueryExpr

type ExistsSubqueryExpr struct {

	// Sel is the subquery, may be rewritten to other type of expression.
	Sel ExprNode
	// Not is true, the expression is "not exists".
	Not bool
	// contains filtered or unexported fields
}

ExistsSubqueryExpr is the expression for "exists (select ...)". See https://dev.mysql.com/doc/refman/5.7/en/exists-and-not-exists-subqueries.html

func (*ExistsSubqueryExpr) Accept

func (n *ExistsSubqueryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ExistsSubqueryExpr) Restore

func (n *ExistsSubqueryExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type ExpAsVar

type ExpAsVar struct {
	Expr   ExprNode
	AsName model.CIStr
	// contains filtered or unexported fields
}

func (*ExpAsVar) Accept

func (e *ExpAsVar) Accept(v Visitor) (node Node, ok bool)

func (*ExpAsVar) OriginTextPosition

func (n *ExpAsVar) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*ExpAsVar) Restore

func (e *ExpAsVar) Restore(ctx *format.RestoreCtx) error

func (*ExpAsVar) SetOriginTextPosition

func (n *ExpAsVar) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*ExpAsVar) SetText

func (n *ExpAsVar) SetText(text string)

SetText implements Node interface.

func (*ExpAsVar) Text

func (n *ExpAsVar) Text() string

Text implements Node interface.

type ExplainStmt

type ExplainStmt struct {
	Select *SelectStmt
	// contains filtered or unexported fields
}

func (*ExplainStmt) Accept

func (e *ExplainStmt) Accept(v Visitor) (node Node, ok bool)

func (*ExplainStmt) Restore

func (e *ExplainStmt) Restore(ctx *format.RestoreCtx) error

type ExprNode

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

ExprNode is a node that can be evaluated. Name of implementations should have 'Expr' suffix.

type ExtractField

type ExtractField byte
const (
	ExtractFieldYear ExtractField = iota
	ExtractFieldMonth
	ExtractFieldDay
	ExtractFieldHour
	ExtractFieldMinute
	ExtractFieldSecond
	ExtractFieldTimezoneHour
	ExtractFieldTimezoneMinute
)

type ExtractFuncExpr

type ExtractFuncExpr struct {
	ExtractField ExtractField
	Expr         ExprNode
	// contains filtered or unexported fields
}

ExtractFuncExpr is for function expression.

func (*ExtractFuncExpr) Accept

func (e *ExtractFuncExpr) Accept(v Visitor) (node Node, ok bool)

func (*ExtractFuncExpr) Restore

func (e *ExtractFuncExpr) Restore(ctx *format.RestoreCtx) error

type FuncCallExpr

type FuncCallExpr struct {

	// FnName is the function name.
	FnName model.CIStr
	// Args is the function args.
	Args []ExprNode
	// contains filtered or unexported fields
}

FuncCallExpr is for function expression.

func (*FuncCallExpr) Accept

func (n *FuncCallExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*FuncCallExpr) Restore

func (n *FuncCallExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type GraphElementInsertion

type GraphElementInsertion struct {
	InsertionType       InsertionType
	VariableName        model.CIStr
	From                model.CIStr
	To                  model.CIStr
	LabelsAndProperties *LabelsAndProperties
	// contains filtered or unexported fields
}

func (*GraphElementInsertion) Accept

func (g *GraphElementInsertion) Accept(v Visitor) (node Node, ok bool)

func (*GraphElementInsertion) OriginTextPosition

func (n *GraphElementInsertion) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*GraphElementInsertion) Restore

func (g *GraphElementInsertion) Restore(ctx *format.RestoreCtx) error

func (*GraphElementInsertion) SetOriginTextPosition

func (n *GraphElementInsertion) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*GraphElementInsertion) SetText

func (n *GraphElementInsertion) SetText(text string)

SetText implements Node interface.

func (*GraphElementInsertion) Text

func (n *GraphElementInsertion) Text() string

Text implements Node interface.

type GraphElementUpdate

type GraphElementUpdate struct {
	VariableName model.CIStr
	Assignments  []*PropertyAssignment
	// contains filtered or unexported fields
}

func (*GraphElementUpdate) Accept

func (g *GraphElementUpdate) Accept(v Visitor) (node Node, ok bool)

func (*GraphElementUpdate) Restore

func (g *GraphElementUpdate) Restore(ctx *format.RestoreCtx) error

type GroupByClause

type GroupByClause struct {
	Items []*ByItem
	// contains filtered or unexported fields
}

func (*GroupByClause) Accept

func (n *GroupByClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*GroupByClause) OriginTextPosition

func (n *GroupByClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*GroupByClause) Restore

func (n *GroupByClause) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*GroupByClause) SetOriginTextPosition

func (n *GroupByClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*GroupByClause) SetText

func (n *GroupByClause) SetText(text string)

SetText implements Node interface.

func (*GroupByClause) Text

func (n *GroupByClause) Text() string

Text implements Node interface.

type HavingClause

type HavingClause struct {
	Expr ExprNode
	// contains filtered or unexported fields
}

HavingClause represents having clause.

func (*HavingClause) Accept

func (n *HavingClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*HavingClause) OriginTextPosition

func (n *HavingClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*HavingClause) Restore

func (n *HavingClause) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*HavingClause) SetOriginTextPosition

func (n *HavingClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*HavingClause) SetText

func (n *HavingClause) SetText(text string)

SetText implements Node interface.

func (*HavingClause) Text

func (n *HavingClause) Text() string

Text implements Node interface.

type IndexKeyType

type IndexKeyType int

IndexKeyType is the type for index key.

const (
	IndexKeyTypeNone IndexKeyType = iota
	IndexKeyTypeUnique
)

Index key types.

type InsertStmt

type InsertStmt struct {
	PathPatternMacros []*PathPatternMacro
	IntoGraphName     model.CIStr
	Insertions        []*GraphElementInsertion

	// Full modify query
	// ref: https://pgql-lang.org/spec/1.5/#insert
	From    *MatchClauseList
	Where   ExprNode
	GroupBy *GroupByClause
	Having  *HavingClause
	OrderBy *OrderByClause
	Limit   *LimitClause
	// contains filtered or unexported fields
}

func (*InsertStmt) Accept

func (n *InsertStmt) Accept(v Visitor) (node Node, ok bool)

func (*InsertStmt) Restore

func (n *InsertStmt) Restore(ctx *format.RestoreCtx) error

type InsertionType

type InsertionType byte
const (
	InsertionTypeVertex InsertionType = 1
	InsertionTypeEdge   InsertionType = 2
)

func (InsertionType) String

func (it InsertionType) String() string

String implements the fmt.Stringer interface

type IsNullExpr

type IsNullExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Not is true, the expression is "is not null".
	Not bool
	// contains filtered or unexported fields
}

IsNullExpr is the expression for null check.

func (*IsNullExpr) Accept

func (n *IsNullExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*IsNullExpr) Restore

func (n *IsNullExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type LabelsAndProperties

type LabelsAndProperties struct {
	Labels      []model.CIStr
	Assignments []*PropertyAssignment
	// contains filtered or unexported fields
}

func (*LabelsAndProperties) Accept

func (l *LabelsAndProperties) Accept(v Visitor) (node Node, ok bool)

func (*LabelsAndProperties) OriginTextPosition

func (n *LabelsAndProperties) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*LabelsAndProperties) Restore

func (l *LabelsAndProperties) Restore(ctx *format.RestoreCtx) error

func (*LabelsAndProperties) SetOriginTextPosition

func (n *LabelsAndProperties) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*LabelsAndProperties) SetText

func (n *LabelsAndProperties) SetText(text string)

SetText implements Node interface.

func (*LabelsAndProperties) Text

func (n *LabelsAndProperties) Text() string

Text implements Node interface.

type LimitClause

type LimitClause struct {
	Count  ExprNode
	Offset ExprNode
	// contains filtered or unexported fields
}

LimitClause is the limit clause.

func (*LimitClause) Accept

func (n *LimitClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*LimitClause) OriginTextPosition

func (n *LimitClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*LimitClause) Restore

func (n *LimitClause) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*LimitClause) SetOriginTextPosition

func (n *LimitClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*LimitClause) SetText

func (n *LimitClause) SetText(text string)

SetText implements Node interface.

func (*LimitClause) Text

func (n *LimitClause) Text() string

Text implements Node interface.

type MatchClause

type MatchClause struct {
	Graph model.CIStr
	Paths []*PathPattern
	// contains filtered or unexported fields
}

func (*MatchClause) Accept

func (n *MatchClause) Accept(v Visitor) (Node, bool)

func (*MatchClause) OriginTextPosition

func (n *MatchClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*MatchClause) Restore

func (n *MatchClause) Restore(ctx *format.RestoreCtx) error

func (*MatchClause) SetOriginTextPosition

func (n *MatchClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*MatchClause) SetText

func (n *MatchClause) SetText(text string)

SetText implements Node interface.

func (*MatchClause) Text

func (n *MatchClause) Text() string

Text implements Node interface.

type MatchClauseList

type MatchClauseList struct {
	Matches []*MatchClause
	// contains filtered or unexported fields
}

func (*MatchClauseList) Accept

func (n *MatchClauseList) Accept(v Visitor) (Node, bool)

func (*MatchClauseList) OriginTextPosition

func (n *MatchClauseList) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*MatchClauseList) Restore

func (n *MatchClauseList) Restore(ctx *format.RestoreCtx) error

func (*MatchClauseList) SetOriginTextPosition

func (n *MatchClauseList) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*MatchClauseList) SetText

func (n *MatchClauseList) SetText(text string)

SetText implements Node interface.

func (*MatchClauseList) Text

func (n *MatchClauseList) Text() string

Text implements Node interface.

type Node

type Node interface {
	// Restore returns the sql text from ast tree
	Restore(ctx *format.RestoreCtx) error
	// Accept accepts Visitor to visit itself.
	// The returned node should replace original node.
	// ok returns false to stop visiting.
	//
	// Implementation of this method should first call visitor.Enter,
	// assign the returned node to its method receiver, if skipChildren returns true,
	// children should be skipped. Otherwise, call its children in particular order that
	// later elements depends on former elements. Finally, return visitor.Leave.
	Accept(v Visitor) (node Node, ok bool)
	// Text returns the original text of the element.
	Text() string
	// SetText sets original text to the Node.
	SetText(text string)
	// SetOriginTextPosition set the start offset of this node in the origin text.
	SetOriginTextPosition(offset int)
	// OriginTextPosition get the start offset of this node in the origin text.
	OriginTextPosition() int
}

Node is the basic element of the AST. Interfaces embed Node should have 'Node' name suffix.

type OrderByClause

type OrderByClause struct {
	Items []*ByItem
	// contains filtered or unexported fields
}

OrderByClause represents order by clause.

func (*OrderByClause) Accept

func (n *OrderByClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*OrderByClause) OriginTextPosition

func (n *OrderByClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*OrderByClause) Restore

func (n *OrderByClause) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*OrderByClause) SetOriginTextPosition

func (n *OrderByClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*OrderByClause) SetText

func (n *OrderByClause) SetText(text string)

SetText implements Node interface.

func (*OrderByClause) Text

func (n *OrderByClause) Text() string

Text implements Node interface.

type ParenthesesExpr

type ParenthesesExpr struct {

	// Expr is the expression in parentheses.
	Expr ExprNode
	// contains filtered or unexported fields
}

ParenthesesExpr is the parentheses expression.

func (*ParenthesesExpr) Accept

func (n *ParenthesesExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ParenthesesExpr) Restore

func (n *ParenthesesExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type PathPattern

type PathPattern struct {
	Tp          PathPatternType
	TopK        int64
	Vertices    []*VertexPattern
	Connections []VertexPairConnection
	// contains filtered or unexported fields
}

func (*PathPattern) Accept

func (n *PathPattern) Accept(v Visitor) (Node, bool)

func (*PathPattern) OriginTextPosition

func (n *PathPattern) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*PathPattern) Restore

func (n *PathPattern) Restore(ctx *format.RestoreCtx) error

func (*PathPattern) SetOriginTextPosition

func (n *PathPattern) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*PathPattern) SetText

func (n *PathPattern) SetText(text string)

SetText implements Node interface.

func (*PathPattern) Text

func (n *PathPattern) Text() string

Text implements Node interface.

type PathPatternMacro

type PathPatternMacro struct {
	Name  model.CIStr
	Path  *PathPattern
	Where ExprNode
	// contains filtered or unexported fields
}

func (*PathPatternMacro) Accept

func (n *PathPatternMacro) Accept(v Visitor) (Node, bool)

func (*PathPatternMacro) OriginTextPosition

func (n *PathPatternMacro) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*PathPatternMacro) Restore

func (n *PathPatternMacro) Restore(ctx *format.RestoreCtx) error

func (*PathPatternMacro) SetOriginTextPosition

func (n *PathPatternMacro) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*PathPatternMacro) SetText

func (n *PathPatternMacro) SetText(text string)

SetText implements Node interface.

func (*PathPatternMacro) Text

func (n *PathPatternMacro) Text() string

Text implements Node interface.

type PathPatternType

type PathPatternType int
const (
	PathPatternSimple PathPatternType = iota
	PathPatternAny
	PathPatternAnyShortest
	PathPatternAllShortest
	PathPatternTopKShortest
	PathPatternAnyCheapest
	PathPatternAllCheapest
	PathPatternTopKCheapest
	PathPatternAll
)

type PatternInExpr

type PatternInExpr struct {

	// Expr is the value expression to be compared.
	Expr ExprNode
	// List is the list expression in compare list.
	List []ExprNode
	// Not is true, the expression is "not in".
	Not bool
	// contains filtered or unexported fields
}

PatternInExpr is the expression for in operator, like "expr in (1, 2, 3)" or "expr in (select c from t)".

func (*PatternInExpr) Accept

func (n *PatternInExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PatternInExpr) Restore

func (n *PatternInExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type PatternQuantifier

type PatternQuantifier struct {
	Tp PatternQuantifierType
	N  int64
	M  int64
	// contains filtered or unexported fields
}

func (*PatternQuantifier) Accept

func (n *PatternQuantifier) Accept(v Visitor) (Node, bool)

func (*PatternQuantifier) OriginTextPosition

func (n *PatternQuantifier) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*PatternQuantifier) Restore

func (n *PatternQuantifier) Restore(ctx *format.RestoreCtx) error

func (*PatternQuantifier) SetOriginTextPosition

func (n *PatternQuantifier) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*PatternQuantifier) SetText

func (n *PatternQuantifier) SetText(text string)

SetText implements Node interface.

func (*PatternQuantifier) Text

func (n *PatternQuantifier) Text() string

Text implements Node interface.

type PatternQuantifierType

type PatternQuantifierType int

type PropertyAccess

type PropertyAccess struct {
	VariableName model.CIStr
	PropertyName model.CIStr
	// contains filtered or unexported fields
}

func (*PropertyAccess) Accept

func (n *PropertyAccess) Accept(v Visitor) (node Node, ok bool)

func (*PropertyAccess) Restore

func (n *PropertyAccess) Restore(ctx *format.RestoreCtx) error

type PropertyAssignment

type PropertyAssignment struct {
	PropertyAccess  *PropertyAccess
	ValueExpression ExprNode
	// contains filtered or unexported fields
}

func (*PropertyAssignment) Accept

func (p *PropertyAssignment) Accept(v Visitor) (node Node, ok bool)

func (*PropertyAssignment) OriginTextPosition

func (n *PropertyAssignment) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*PropertyAssignment) Restore

func (p *PropertyAssignment) Restore(ctx *format.RestoreCtx) error

func (*PropertyAssignment) SetOriginTextPosition

func (n *PropertyAssignment) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*PropertyAssignment) SetText

func (n *PropertyAssignment) SetText(text string)

SetText implements Node interface.

func (*PropertyAssignment) Text

func (n *PropertyAssignment) Text() string

Text implements Node interface.

type QuantifiedPathExpr

type QuantifiedPathExpr struct {
	Edge        *EdgePattern
	Quantifier  *PatternQuantifier
	Source      *VertexPattern
	Destination *VertexPattern
	Where       ExprNode
	Cost        ExprNode
	// contains filtered or unexported fields
}

func (*QuantifiedPathExpr) Accept

func (n *QuantifiedPathExpr) Accept(v Visitor) (Node, bool)

func (*QuantifiedPathExpr) OriginTextPosition

func (n *QuantifiedPathExpr) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*QuantifiedPathExpr) Restore

func (n *QuantifiedPathExpr) Restore(ctx *format.RestoreCtx) error

func (*QuantifiedPathExpr) SetOriginTextPosition

func (n *QuantifiedPathExpr) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*QuantifiedPathExpr) SetText

func (n *QuantifiedPathExpr) SetText(text string)

SetText implements Node interface.

func (*QuantifiedPathExpr) Text

func (n *QuantifiedPathExpr) Text() string

Text implements Node interface.

type ReachabilityPathExpr

type ReachabilityPathExpr struct {
	Labels     []model.CIStr
	Direction  EdgeDirection
	Quantifier *PatternQuantifier
	// Variable name is not supported in ReachabilityPathExpr.
	// But we need an anonymous name for building logical plan.
	AnonymousName model.CIStr
	// Macros will be assigned in MacroExpansion stage.
	// LabelName(lower) -> PathPattern
	Macros map[string]*PathPattern
	// contains filtered or unexported fields
}

func (*ReachabilityPathExpr) Accept

func (n *ReachabilityPathExpr) Accept(v Visitor) (Node, bool)

func (*ReachabilityPathExpr) OriginTextPosition

func (n *ReachabilityPathExpr) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*ReachabilityPathExpr) Restore

func (n *ReachabilityPathExpr) Restore(ctx *format.RestoreCtx) error

func (*ReachabilityPathExpr) SetOriginTextPosition

func (n *ReachabilityPathExpr) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*ReachabilityPathExpr) SetText

func (n *ReachabilityPathExpr) SetText(text string)

SetText implements Node interface.

func (*ReachabilityPathExpr) Text

func (n *ReachabilityPathExpr) Text() string

Text implements Node interface.

type RollbackStmt

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

func (*RollbackStmt) Accept

func (r *RollbackStmt) Accept(v Visitor) (node Node, ok bool)

func (*RollbackStmt) OriginTextPosition

func (n *RollbackStmt) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*RollbackStmt) Restore

func (r *RollbackStmt) Restore(ctx *format.RestoreCtx) error

func (*RollbackStmt) SetOriginTextPosition

func (n *RollbackStmt) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*RollbackStmt) SetText

func (n *RollbackStmt) SetText(text string)

SetText implements Node interface.

func (*RollbackStmt) Text

func (n *RollbackStmt) Text() string

Text implements Node interface.

type SelectClause

type SelectClause struct {
	Star     bool
	Distinct bool
	Elements []*SelectElement
	// contains filtered or unexported fields
}

func (*SelectClause) Accept

func (n *SelectClause) Accept(v Visitor) (node Node, ok bool)

func (*SelectClause) OriginTextPosition

func (n *SelectClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*SelectClause) Restore

func (n *SelectClause) Restore(ctx *format.RestoreCtx) error

func (*SelectClause) SetOriginTextPosition

func (n *SelectClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*SelectClause) SetText

func (n *SelectClause) SetText(text string)

SetText implements Node interface.

func (*SelectClause) Text

func (n *SelectClause) Text() string

Text implements Node interface.

type SelectElement

type SelectElement struct {
	ExpAsVar *ExpAsVar

	// All Properties with optional prefix
	Identifier string
	Prefix     string
	// contains filtered or unexported fields
}

SelectElement represents a result field which can be a property from a label, or an expression in select field. It is a generated property during binding process. SelectElement is the key element to evaluate a PropertyNameExpr.

func (*SelectElement) Accept

func (n *SelectElement) Accept(v Visitor) (node Node, ok bool)

func (*SelectElement) OriginTextPosition

func (n *SelectElement) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*SelectElement) Restore

func (n *SelectElement) Restore(ctx *format.RestoreCtx) error

func (*SelectElement) SetOriginTextPosition

func (n *SelectElement) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*SelectElement) SetText

func (n *SelectElement) SetText(text string)

SetText implements Node interface.

func (*SelectElement) Text

func (n *SelectElement) Text() string

Text implements Node interface.

type SelectStmt

type SelectStmt struct {
	PathPatternMacros []*PathPatternMacro
	Select            *SelectClause
	From              *MatchClauseList
	Where             ExprNode
	GroupBy           *GroupByClause
	Having            *HavingClause
	OrderBy           *OrderByClause
	Limit             *LimitClause
	// contains filtered or unexported fields
}

func (*SelectStmt) Accept

func (n *SelectStmt) Accept(v Visitor) (node Node, ok bool)

func (*SelectStmt) Restore

func (n *SelectStmt) Restore(ctx *format.RestoreCtx) error

type ShowStmt

type ShowStmt struct {
	Tp        ShowTarget
	GraphName model.CIStr
	// contains filtered or unexported fields
}

func (*ShowStmt) Accept

func (s *ShowStmt) Accept(v Visitor) (node Node, ok bool)

func (*ShowStmt) Restore

func (s *ShowStmt) Restore(ctx *format.RestoreCtx) error

type ShowTarget

type ShowTarget byte
const (
	ShowTargetGraphs ShowTarget = iota + 1
	ShowTargetLabels
)

type StmtNode

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

StmtNode represents statement node. Name of implementations should have 'Stmt' suffix.

type SubqueryExpr

type SubqueryExpr struct {

	// Query is the query SelectNode.
	Query      *SelectStmt
	Evaluated  bool
	Correlated bool
	MultiRows  bool
	Exists     bool
	// contains filtered or unexported fields
}

SubqueryExpr represents a subquery.

func (*SubqueryExpr) Accept

func (n *SubqueryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*SubqueryExpr) Restore

func (n *SubqueryExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type SubstrFuncExpr

type SubstrFuncExpr struct {
	Expr  ExprNode
	Start ExprNode
	For   ExprNode
	// contains filtered or unexported fields
}

SubstrFuncExpr is for function expression.

func (*SubstrFuncExpr) Accept

func (s *SubstrFuncExpr) Accept(v Visitor) (node Node, ok bool)

func (*SubstrFuncExpr) Restore

func (s *SubstrFuncExpr) Restore(ctx *format.RestoreCtx) error

type UnaryExpr

type UnaryExpr struct {

	// Op is the operator opcode.
	Op opcode.Op
	// V is the unary expression.
	V ExprNode
	// contains filtered or unexported fields
}

UnaryExpr is the expression for unary operator.

func (*UnaryExpr) Accept

func (n *UnaryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*UnaryExpr) Restore

func (n *UnaryExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type UpdateStmt

type UpdateStmt struct {
	PathPatternMacros []*PathPatternMacro
	Updates           []*GraphElementUpdate

	// Full modify query
	// ref: https://pgql-lang.org/spec/1.5/#insert
	From    *MatchClauseList
	Where   ExprNode
	GroupBy *GroupByClause
	Having  *HavingClause
	OrderBy *OrderByClause
	Limit   *LimitClause
	// contains filtered or unexported fields
}

func (*UpdateStmt) Accept

func (n *UpdateStmt) Accept(v Visitor) (node Node, ok bool)

func (*UpdateStmt) Restore

func (n *UpdateStmt) Restore(ctx *format.RestoreCtx) error

type UseStmt

type UseStmt struct {
	GraphName model.CIStr
	// contains filtered or unexported fields
}

func (*UseStmt) Accept

func (u *UseStmt) Accept(v Visitor) (node Node, ok bool)

func (*UseStmt) Restore

func (u *UseStmt) Restore(ctx *format.RestoreCtx) error

type ValueExpr

type ValueExpr struct {
	datum.Datum
	// contains filtered or unexported fields
}

ValueExpr is the simple value expression.

func NewValueExpr

func NewValueExpr(lit interface{}) *ValueExpr

NewValueExpr creates a ValueExpr with value, and sets default field type.

func (*ValueExpr) Accept

func (n *ValueExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*ValueExpr) Restore

func (n *ValueExpr) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

type VariableReference

type VariableReference struct {
	VariableName model.CIStr
	// contains filtered or unexported fields
}

func (*VariableReference) Accept

func (n *VariableReference) Accept(v Visitor) (node Node, ok bool)

func (*VariableReference) Restore

func (n *VariableReference) Restore(ctx *format.RestoreCtx) error

type VariableSpec

type VariableSpec struct {
	Name      model.CIStr
	Labels    []model.CIStr
	Anonymous bool
	// contains filtered or unexported fields
}

func (*VariableSpec) Accept

func (n *VariableSpec) Accept(v Visitor) (Node, bool)

func (*VariableSpec) OriginTextPosition

func (n *VariableSpec) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*VariableSpec) Restore

func (n *VariableSpec) Restore(ctx *format.RestoreCtx) error

func (*VariableSpec) SetOriginTextPosition

func (n *VariableSpec) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*VariableSpec) SetText

func (n *VariableSpec) SetText(text string)

SetText implements Node interface.

func (*VariableSpec) Text

func (n *VariableSpec) Text() string

Text implements Node interface.

type VertexPairConnection

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

type VertexPattern

type VertexPattern struct {
	Variable *VariableSpec
	// contains filtered or unexported fields
}

func (*VertexPattern) Accept

func (n *VertexPattern) Accept(v Visitor) (Node, bool)

func (*VertexPattern) OriginTextPosition

func (n *VertexPattern) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*VertexPattern) Restore

func (n *VertexPattern) Restore(ctx *format.RestoreCtx) error

func (*VertexPattern) SetOriginTextPosition

func (n *VertexPattern) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*VertexPattern) SetText

func (n *VertexPattern) SetText(text string)

SetText implements Node interface.

func (*VertexPattern) Text

func (n *VertexPattern) Text() string

Text implements Node interface.

type Visitor

type Visitor interface {
	// Enter is called before children nodes are visited.
	// The returned node must be the same type as the input node n.
	// skipChildren returns true means children nodes should be skipped,
	// this is useful when work is done in Enter and there is no need to visit children.
	Enter(n Node) (node Node, skipChildren bool)
	// Leave is called after children nodes have been visited.
	// The returned node's type can be different from the input node if it is a ExprNode,
	// Non-expression node must be the same type as the input node n.
	// ok returns false to stop visiting.
	Leave(n Node) (node Node, ok bool)
}

Visitor visits a Node.

type WhenClause

type WhenClause struct {

	// Expr is the condition expression in WhenClause.
	Expr ExprNode
	// Result is the result expression in WhenClause.
	Result ExprNode
	// contains filtered or unexported fields
}

WhenClause is the when clause in Case expression for "when condition then result".

func (*WhenClause) Accept

func (n *WhenClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*WhenClause) OriginTextPosition

func (n *WhenClause) OriginTextPosition() int

OriginTextPosition implements Node interface.

func (*WhenClause) Restore

func (n *WhenClause) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*WhenClause) SetOriginTextPosition

func (n *WhenClause) SetOriginTextPosition(offset int)

SetOriginTextPosition implements Node interface.

func (*WhenClause) SetText

func (n *WhenClause) SetText(text string)

SetText implements Node interface.

func (*WhenClause) Text

func (n *WhenClause) Text() string

Text implements Node interface.

Jump to

Keyboard shortcuts

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