parser

package
v0.0.0-...-c5e5643 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvBinaryOpExpReafToExpIFOne

func ConvBinaryOpExpReafToExpIFOne(sc *schema.Schema, convSrc interface{}) expression.Expression

attiontion: this func can be used only for predicate of SelectionPlanNode

func ConvColumnStrsToExpIfOnes

func ConvColumnStrsToExpIfOnes(c *catalog.Catalog, childPlan plans.Plan, convSrc []*string, isLeftOnJoin bool) []expression.Expression

childPlan can be nil

func ConvParsedBinaryOpExprToExpIFOne

func ConvParsedBinaryOpExprToExpIFOne(sc *schema.Schema, convSrc *BinaryOpExpression) expression.Expression

attiontion: this func can be used only for predicate of SelectionPlanNode

func ConvParsedSelectionExprToSchema

func ConvParsedSelectionExprToSchema(c *catalog.Catalog, convSrc []*SelectFieldExpression) *schema.Schema

TODO: (SDB) need to support aggregation function on select field

func GetPredicateExprFromStr

func GetPredicateExprFromStr(schema_ *schema.Schema, pred *string) expression.Expression

func GetTypesForBOperationExpr

func GetTypesForBOperationExpr(opcode_ opcode.Op) (expression.LogicalOpType, expression.ComparisonType)

func PrintParsedNodes

func PrintParsedNodes(sqlStr *string)

for utity func on develop phase

func ValueExprToValue

func ValueExprToValue(expr *driver.ValueExpr) *types.Value

Types

type AggFuncVisitor

type AggFuncVisitor struct {
	ColumnName_ *string
	TableName_  *string
}

func (*AggFuncVisitor) Enter

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

func (*AggFuncVisitor) Leave

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

type AssignVisitor

type AssignVisitor struct {
	Colname_ *string
	Value_   *types.Value
}

func (*AssignVisitor) Enter

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

func (*AssignVisitor) Leave

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

type BinaryOpExpType

type BinaryOpExpType int
const (
	Compare BinaryOpExpType = iota
	Logical
	IsNull
	ColumnName
	Constant
)

type BinaryOpExpression

type BinaryOpExpression struct {
	LogicalOperationType_    expression.LogicalOpType
	ComparisonOperationType_ expression.ComparisonType
	Left_                    interface{}
	Right_                   interface{}
}

func (*BinaryOpExpression) AppendBinaryOpExpWithAnd

func (expr *BinaryOpExpression) AppendBinaryOpExpWithAnd(expr2 *BinaryOpExpression) *BinaryOpExpression

func (*BinaryOpExpression) GetDeepCopy

func (expr *BinaryOpExpression) GetDeepCopy() *BinaryOpExpression

func (*BinaryOpExpression) GetType

func (expr *BinaryOpExpression) GetType() BinaryOpExpType

func (*BinaryOpExpression) TouchedColumns

func (expr *BinaryOpExpression) TouchedColumns() mapset.Set[string]

type BinaryOpVisitor

type BinaryOpVisitor struct {
	QueryInfo_          *QueryInfo
	BinaryOpExpression_ *BinaryOpExpression
}

func (*BinaryOpVisitor) Enter

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

func (*BinaryOpVisitor) Leave

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

type ChildDataVisitor

type ChildDataVisitor struct {
	ChildDatas_ []interface{}
}

func (*ChildDataVisitor) Enter

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

func (*ChildDataVisitor) Leave

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

type ColDefExpression

type ColDefExpression struct {
	ColName_ *string
	ColType_ *types.TypeID
}

type IndexDefExpression

type IndexDefExpression struct {
	IndexName_ *string
	Colnames_  []*string
}

type JoinVisitor

type JoinVisitor struct {
	QueryInfo_ *QueryInfo
}

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 OrderByExpression

type OrderByExpression struct {
	IsDesc_  bool
	ColName_ *string
}

type PrintNodesVisitor

type PrintNodesVisitor struct {
}

func NewPrintNodesVisitor

func NewPrintNodesVisitor() *PrintNodesVisitor

func (*PrintNodesVisitor) Enter

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

func (*PrintNodesVisitor) Leave

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

type QueryInfo

type QueryInfo struct {
	QueryType_           *QueryType
	SelectFields_        []*SelectFieldExpression // SELECT
	SetExpressions_      []*SetExpression         // UPDATE
	NewTable_            *string                  // CREATE TABLE
	ColDefExpressions_   []*ColDefExpression      // CREATE TABLE
	IndexDefExpressions_ []*IndexDefExpression    // CREATE TABLE
	TargetCols_          []*string                // INSERT
	Values_              []*types.Value           // INSERT
	OnExpressions_       *BinaryOpExpression      // SELECT (with JOIN)
	JoinTables_          []*string                // SELECT
	WhereExpression_     *BinaryOpExpression      // SELECT, UPDATE, DELETE
	LimitNum_            int32                    // SELECT
	OffsetNum_           int32                    // SELECT
	OrderByExpressions_  []*OrderByExpression     // SELECT
}

func ProcessSQLStr

func ProcessSQLStr(sqlStr *string) (*QueryInfo, error)

type QueryType

type QueryType int32
const (
	SELECT QueryType = iota
	CREATE_TABLE
	INSERT
	DELETE
	UPDATE
)

type RootSQLVisitor

type RootSQLVisitor struct {
	QueryInfo_ *QueryInfo
}

func NewRootSQLVisitor

func NewRootSQLVisitor() *RootSQLVisitor

func (*RootSQLVisitor) Enter

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

func (*RootSQLVisitor) Leave

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

type SelectFieldExpression

type SelectFieldExpression struct {
	IsAgg_     bool
	AggType_   plans.AggregationType
	TableName_ *string // if specified
	ColName_   *string
}

func (*SelectFieldExpression) TouchedColumns

func (sf *SelectFieldExpression) TouchedColumns() mapset.Set[string]

type SelectFieldsVisitor

type SelectFieldsVisitor struct {
	QueryInfo_ *QueryInfo
}

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 SetExpression

type SetExpression struct {
	ColName_     *string
	UpdateValue_ *types.Value
}

type Visitor

type Visitor interface {
	Enter(n ast.Node) (node ast.Node, skipChildren bool)
	Leave(n ast.Node) (node ast.Node, ok bool)
}

Jump to

Keyboard shortcuts

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