parser

package
v0.0.0-...-7037cb6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstantValue

type ConstantValue struct {
	DataType    base.ValueType
	IntValue    int64
	FloatValue  float64
	StringValue string
}

type ExpressionType

type ExpressionType int

Expression Type

const (
	// Column Name
	ExpTypeLogicalExpression ExpressionType = iota

	// Column Name
	ExpTypeColumnNameExpression

	// Value Expression (i.e a constant of some sort)
	ExpTypeValueExpression
)

type JoinInfo

type JoinInfo struct {
	LeftSource  string
	LeftColumn  string
	RightSource string
	RightColumn string
}

type JoinParseState

type JoinParseState int

Join Parser state type

const (
	// Parsing None
	ParsingJoinNone JoinParseState = iota

	// Parsing Join Node
	ParsingJoinNode

	// Parsing sources
	ParsingJoinSources

	// Parsing Join Node
	ParsingJoinTableJoinNode

	// Parsing the ON Node
	ParsingJoinOnNode

	// Parsing Left Node
	ParsingJoinLeftNode

	// Parsing Right Node
	ParsingJoinRightNode
)

type JoinVisitor

type JoinVisitor struct {
	CurrentJoinParseState JoinParseState

	// All sources
	Sources []*SourceInfo

	// All the joins
	Joins []*JoinInfo

	// Currently parsing join
	CurrentJoin *JoinInfo

	// Currently parsing source
	CurrentSource *SourceInfo

	// Is the state valid
	IsValid bool

	// Error
	Error error

	// Parsing text info
	ParsingText string
}

func NewJoinVisitor

func NewJoinVisitor() *JoinVisitor

Create a new join visitor

func (*JoinVisitor) Enter

func (v *JoinVisitor) Enter(in ast.Node) (ast.Node, bool)

func (*JoinVisitor) Leave

func (v *JoinVisitor) Leave(in ast.Node) (ast.Node, bool)

type ParseState

type ParseState int

Parse state type

const (
	// Parsing None
	ParsingNone ParseState = iota

	// Parsing Select
	ParsingSelect

	// Parsing From
	ParsingFrom

	// Parsing Where
	ParsingWhere

	// Parsing  GroupBy
	ParsingGroupBy

	// Parsing Having
	ParsingHaving

	// Parsing OrderBy
	ParsingOrderBy
)

type Parser

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

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(sql string) (*base.QueryOps, error)

type SelectFieldInfo

type SelectFieldInfo struct {
	Attribute         string
	Series            string
	SeriesFamilyAlias string
	FieldAlias        string
}

Boost Select Field specification states that the field selection can either be a series value or series attribute. The field selection is of the form: [Alias].[Series] is the syntactic sugar for [Alias].[Series].value [Alias].[Series].[Attribute] is the fully qualified field name

type SelectFieldsParseState

type SelectFieldsParseState int

Select Field Parser state type

const (
	// Parsing None
	ParsingSelectFieldNone SelectFieldsParseState = iota

	// Parsing the root node that holds all the Fields
	ParsingSelectFieldsNode

	// Parsing a specific Field
	ParsingSelectField

	// Parsing a column name expression node
	ParsingSelectColNameExprNode

	// Parsing a column name node
	ParsingSelectColNameNode
)

type SelectFieldsVisitor

type SelectFieldsVisitor struct {
	CurrentParseState SelectFieldsParseState

	// Is state invalid
	IsInvalid bool

	// Error message
	Error error

	// Parsing text
	ParsingText string

	// All the fields in the select statement
	Fields []*SelectFieldInfo
	// contains filtered or unexported fields
}

func NewSelectFieldsVisitor

func NewSelectFieldsVisitor() *SelectFieldsVisitor

Create a new select fields visitor

func (*SelectFieldsVisitor) Enter

func (v *SelectFieldsVisitor) Enter(in ast.Node) (ast.Node, bool)

func (*SelectFieldsVisitor) Leave

func (v *SelectFieldsVisitor) Leave(in ast.Node) (ast.Node, bool)

type SourceInfo

type SourceInfo struct {
	SourceDomain string
	SourceName   string
	SourceType   string
	Alias        string
}

type Visitor

type Visitor struct {
	CurrentParseState ParseState

	// Error message
	Error error
	// contains filtered or unexported fields
}

Visitor Visitor

func (*Visitor) Enter

func (v *Visitor) Enter(in ast.Node) (ast.Node, bool)

func (*Visitor) Leave

func (v *Visitor) Leave(in ast.Node) (ast.Node, bool)

type WhereExpression

type WhereExpression struct {
	Left              *WhereExpression
	Right             *WhereExpression
	Operator          WhereOperatorType
	Attribute         string
	Series            string
	SeriesFamilyAlias string
	Type              ExpressionType
	ValueData         ConstantValue
}

type WhereExpressionVisitor

type WhereExpressionVisitor struct {
	CurrentParseState WhereParseState

	// Is state valid
	IsValid bool

	// Error message
	Error error

	// Parsing text
	ParsingText string

	// Expression Stack
	RootExpression *WhereExpression
	// contains filtered or unexported fields
}

func NewWhereExpressionVisitor

func NewWhereExpressionVisitor() *WhereExpressionVisitor

Create a new where expression visitor

func (*WhereExpressionVisitor) Enter

func (v *WhereExpressionVisitor) Enter(in ast.Node) (ast.Node, bool)

func (*WhereExpressionVisitor) Leave

func (v *WhereExpressionVisitor) Leave(in ast.Node) (ast.Node, bool)

type WhereOperatorType

type WhereOperatorType int

Where Operator Type

const (
	// Unknown
	WhereOpUnknown WhereOperatorType = iota

	// Greater than or equal
	WhereOpGEQ

	// Less than or equal
	WhereOpLEQ

	// Equal
	WhereOpEQ

	// Not Equal
	WhereOpNEQ

	// Less than
	WhereOpLT

	// Greater than
	WhereOpGT

	// Conjunction operator
	WhereOpAND

	// Disjunction operator
	WhereOpOR
)

type WhereParseState

type WhereParseState int

Where Parser state type

const (
	// Parsing None
	ParsingWhereNone WhereParseState = iota

	// Parsing the root node that holds all the expressions
	ParsingWhereFieldsNode

	// Parsing a binary expression
	ParsingWhereBinaryExp

	// Parsing a column name expression node
	ParsingWhereColNameExprNode

	// Parsing a column name node
	ParsingWhereColNameNode
)

Jump to

Keyboard shortcuts

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