planners

package
v0.0.0-...-e6fb8a6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExpression

func BuildExpression(plan IPlan) (expressions.IExpression, error)

func BuildExpressions

func BuildExpressions(plan *MapPlan) ([]expressions.IExpression, error)

func BuildVariableValues

func BuildVariableValues(plan IPlan) ([]string, error)

func CheckAggregateExpressions

func CheckAggregateExpressions(plan IPlan) (bool, error)

func Walk

func Walk(visit Visit, plans ...IPlan) error

Types

type AliasedExpressionPlan

type AliasedExpressionPlan struct {
	Name string

	// 变量的名称
	As string

	// 变量的计算方式
	Expr IPlan
}

func NewAliasedExpressionPlan

func NewAliasedExpressionPlan(as string, expr IPlan) *AliasedExpressionPlan

func (*AliasedExpressionPlan) Build

func (plan *AliasedExpressionPlan) Build() error

func (*AliasedExpressionPlan) String

func (plan *AliasedExpressionPlan) String() string

func (*AliasedExpressionPlan) Walk

func (plan *AliasedExpressionPlan) Walk(visit Visit) error

type BinaryExpressionPlan

type BinaryExpressionPlan struct {
	Name string

	// 这里认为是函数才会有二元操作,所以需要一个函数的名字
	FuncName string

	// 第一个操作单元
	Left IPlan

	//
	Right IPlan
}

用来组合两个Plan

func NewBinaryExpressionPlan

func NewBinaryExpressionPlan(funcName string, left IPlan, right IPlan) *BinaryExpressionPlan

func (*BinaryExpressionPlan) Build

func (plan *BinaryExpressionPlan) Build() error

func (*BinaryExpressionPlan) String

func (plan *BinaryExpressionPlan) String() string

func (*BinaryExpressionPlan) Walk

func (plan *BinaryExpressionPlan) Walk(visit Visit) error

type ConstantPlan

type ConstantPlan struct {
	Name string

	// 要返回的值
	Value interface{}
}

返回固定的常量值

func NewConstantPlan

func NewConstantPlan(value interface{}) *ConstantPlan

func (*ConstantPlan) Build

func (plan *ConstantPlan) Build() error

func (*ConstantPlan) String

func (plan *ConstantPlan) String() string

func (*ConstantPlan) Walk

func (plan *ConstantPlan) Walk(visit Visit) error

type CreateDatabasePlan

type CreateDatabasePlan struct {
	Ast *sqlparser.DBDDL
}

创建数据库的Plan

func (*CreateDatabasePlan) Build

func (plan *CreateDatabasePlan) Build() error

func (*CreateDatabasePlan) Name

func (plan *CreateDatabasePlan) Name() string

func (*CreateDatabasePlan) String

func (plan *CreateDatabasePlan) String() string

func (*CreateDatabasePlan) Walk

func (plan *CreateDatabasePlan) Walk(visit Visit) error

type CreateTablePlan

type CreateTablePlan struct {
	Name string
	Ast  *sqlparser.DDL
}

func (*CreateTablePlan) Build

func (plan *CreateTablePlan) Build() error

func (*CreateTablePlan) String

func (plan *CreateTablePlan) String() string

func (*CreateTablePlan) Walk

func (plan *CreateTablePlan) Walk(visit Visit) error

type DropDatabasePlan

type DropDatabasePlan struct {
	Name string
	Ast  *sqlparser.DBDDL
}

func (*DropDatabasePlan) Build

func (plan *DropDatabasePlan) Build() error

func (*DropDatabasePlan) String

func (plan *DropDatabasePlan) String() string

func (*DropDatabasePlan) Walk

func (plan *DropDatabasePlan) Walk(visit Visit) error

type DropTablePlan

type DropTablePlan struct {
	Name string
	Ast  *sqlparser.DDL
}

func (*DropTablePlan) Build

func (plan *DropTablePlan) Build() error

func (*DropTablePlan) String

func (plan *DropTablePlan) String() string

func (*DropTablePlan) Walk

func (plan *DropTablePlan) Walk(visit Visit) error

type FilterPlan

type FilterPlan struct {
	Name    string
	SubPlan IPlan
}

func NewFilterPlan

func NewFilterPlan(plan IPlan) *FilterPlan

func (*FilterPlan) Build

func (plan *FilterPlan) Build() error

func (*FilterPlan) String

func (plan *FilterPlan) String() string

func (*FilterPlan) Walk

func (plan *FilterPlan) Walk(visit Visit) error

type FunctionExpressionPlan

type FunctionExpressionPlan struct {
	Name     string
	FuncName string
	Args     []IPlan
}

func NewFunctionExpressionPlan

func NewFunctionExpressionPlan(funcName string, args ...IPlan) *FunctionExpressionPlan

func (*FunctionExpressionPlan) Build

func (plan *FunctionExpressionPlan) Build() error

func (*FunctionExpressionPlan) String

func (plan *FunctionExpressionPlan) String() string

func (*FunctionExpressionPlan) Walk

func (plan *FunctionExpressionPlan) Walk(visit Visit) error

type IPlan

type IPlan interface {
	Build() error
	Walk(visit Visit) error
	String() string
}

func NewCreateDatabasePlan

func NewCreateDatabasePlan(ast sqlparser.Statement) IPlan

func NewCreateTablePlan

func NewCreateTablePlan(ast sqlparser.Statement) IPlan

func NewDropDatabasePlan

func NewDropDatabasePlan(ast sqlparser.Statement) IPlan

func NewDropTablePlan

func NewDropTablePlan(ast sqlparser.Statement) IPlan

func NewInsertPlan

func NewInsertPlan(ast sqlparser.Statement) IPlan

func NewSelectPlan

func NewSelectPlan(ast sqlparser.Statement) IPlan

func NewShowDatabasesPlan

func NewShowDatabasesPlan(ast sqlparser.Statement) IPlan

func NewShowTablesPlan

func NewShowTablesPlan(ast sqlparser.Statement) IPlan

func NewUsePlan

func NewUsePlan(ast sqlparser.Statement) IPlan

func PlanFactory

func PlanFactory(query string) (IPlan, error)

type InsertPlan

type InsertPlan struct {
	Name   string
	Schema string
	Table  string
	Format string
}

func (*InsertPlan) Build

func (plan *InsertPlan) Build() error

func (*InsertPlan) String

func (plan *InsertPlan) String() string

func (*InsertPlan) Walk

func (plan *InsertPlan) Walk(visit Visit) error

type LimitPlan

type LimitPlan struct {
	Name         string
	OffsetPlan   IPlan
	RowcountPlan IPlan
}

func NewLimitPlan

func NewLimitPlan(offset, rowcount IPlan) *LimitPlan

func (*LimitPlan) Build

func (plan *LimitPlan) Build() error

func (*LimitPlan) String

func (plan *LimitPlan) String() string

func (*LimitPlan) Walk

func (plan *LimitPlan) Walk(visit Visit) error

type MapPlan

type MapPlan struct {
	Name     string
	SubPlans []IPlan `json:",omitempty"`
}

用来连接Plan和Subplan,连接成一颗树

func NewMapPlan

func NewMapPlan(plans ...IPlan) *MapPlan

func (*MapPlan) Add

func (plan *MapPlan) Add(p IPlan)

func (*MapPlan) AsPlans

func (plan *MapPlan) AsPlans() []IPlan

func (*MapPlan) Build

func (plan *MapPlan) Build() error

func (*MapPlan) Length

func (plan *MapPlan) Length() int

func (*MapPlan) String

func (plan *MapPlan) String() string

func (*MapPlan) Walk

func (plan *MapPlan) Walk(visit Visit) error

type Operator

type Operator string
const (
	OperatorEqual        Operator = "="
	OperatorNotEqual     Operator = "!="
	OperatorMoreThan     Operator = ">"
	OperatorLessThan     Operator = "<"
	OperatorLike         Operator = "like"
	OperatorIn           Operator = "in"
	OperatorNotIn        Operator = "not in"
	OperatorGreaterEqual Operator = ">="
	OperatorLessEqual    Operator = "<="
	OperatorMod          Operator = "%"
	OperatorPlus         Operator = "+"
)

type Order

type Order struct {
	Expression IPlan
	Direction  string
}

type OrderByPlan

type OrderByPlan struct {
	Name   string
	Orders []Order
}

func NewOrderByPlan

func NewOrderByPlan(orders ...Order) *OrderByPlan

func (*OrderByPlan) Build

func (plan *OrderByPlan) Build() error

func (*OrderByPlan) String

func (plan *OrderByPlan) String() string

func (*OrderByPlan) Walk

func (plan *OrderByPlan) Walk(visit Visit) error

type ProjectionPlan

type ProjectionPlan struct {
	Name        string
	Projections *MapPlan `json:",omitempty"`
}

func NewProjectPlan

func NewProjectPlan(plan *MapPlan) *ProjectionPlan

func (*ProjectionPlan) Build

func (plan *ProjectionPlan) Build() error

func (*ProjectionPlan) String

func (plan *ProjectionPlan) String() string

func (*ProjectionPlan) Walk

func (plan *ProjectionPlan) Walk(visit Visit) error

type ScanPlan

type ScanPlan struct {
	Name    string
	Table   string
	Schema  string
	Filter  *FilterPlan     `json:",omitempty"`
	Project *ProjectionPlan `json:",omitempty"`
}

func NewScanPlan

func NewScanPlan(table string, schema string) *ScanPlan

func (*ScanPlan) Build

func (plan *ScanPlan) Build() error

func (*ScanPlan) String

func (plan *ScanPlan) String() string

func (*ScanPlan) Walk

func (plan *ScanPlan) Walk(visit Visit) error

type SelectPlan

type SelectPlan struct {
	Name    string
	SubPlan *MapPlan `json:",omitempty"`
	// contains filtered or unexported fields
}

func (*SelectPlan) Build

func (plan *SelectPlan) Build() error

func (*SelectPlan) String

func (plan *SelectPlan) String() string

func (*SelectPlan) Walk

func (plan *SelectPlan) Walk(visit Visit) error

type SelectionMode

type SelectionMode string
const (
	NormalSelection    SelectionMode = "NormalSelection"
	AggregateSelection SelectionMode = "AggregateSelection"
	GroupBySelection   SelectionMode = "GroupBySelection"
)

type SelectionPlan

type SelectionPlan struct {
	Name          string
	Projects      *MapPlan `json:",omitempty"`
	GroupBys      *MapPlan `json:",omitempty"`
	SelectionMode SelectionMode
}

func NewSelectionPlan

func NewSelectionPlan(projects *MapPlan, groupbys *MapPlan) *SelectionPlan

func (*SelectionPlan) Build

func (plan *SelectionPlan) Build() error

func (*SelectionPlan) String

func (plan *SelectionPlan) String() string

func (*SelectionPlan) Walk

func (plan *SelectionPlan) Walk(visit Visit) error

type ShowDatabasesPlan

type ShowDatabasesPlan struct {
	Name    string
	SubPlan IPlan
}

func (*ShowDatabasesPlan) Build

func (plan *ShowDatabasesPlan) Build() error

func (*ShowDatabasesPlan) String

func (plan *ShowDatabasesPlan) String() string

func (*ShowDatabasesPlan) Walk

func (plan *ShowDatabasesPlan) Walk(visit Visit) error

type ShowTablesPlan

type ShowTablesPlan struct {
	Name    string
	SubPlan IPlan
	// contains filtered or unexported fields
}

func (*ShowTablesPlan) Build

func (plan *ShowTablesPlan) Build() error

func (*ShowTablesPlan) GetAst

func (plan *ShowTablesPlan) GetAst() *sqlparser.Show

func (*ShowTablesPlan) String

func (plan *ShowTablesPlan) String() string

func (*ShowTablesPlan) Walk

func (plan *ShowTablesPlan) Walk(visit Visit) error

type SinkPlan

type SinkPlan struct {
	Name string
}

func NewSinkPlan

func NewSinkPlan() *SinkPlan

func (*SinkPlan) Build

func (plan *SinkPlan) Build() error

func (*SinkPlan) String

func (plan *SinkPlan) String() string

func (*SinkPlan) Walk

func (plan *SinkPlan) Walk(visit Visit) error

type TableValuedFunctionExpressionPlan

type TableValuedFunctionExpressionPlan struct {
	Name     string
	FuncName string
	SubPlan  IPlan
}

func NewTableValuedFunctionExpressionPlan

func NewTableValuedFunctionExpressionPlan(name string, plan IPlan) *TableValuedFunctionExpressionPlan

func (*TableValuedFunctionExpressionPlan) Build

func (*TableValuedFunctionExpressionPlan) String

func (*TableValuedFunctionExpressionPlan) Walk

func (plan *TableValuedFunctionExpressionPlan) Walk(visit Visit) error

type TableValuedFunctionPlan

type TableValuedFunctionPlan struct {
	Name     string
	As       string
	FuncName string
	SubPlan  *MapPlan
}

func NewTableValuedFunctionPlan

func NewTableValuedFunctionPlan(name string, plan *MapPlan) *TableValuedFunctionPlan

func (*TableValuedFunctionPlan) Build

func (plan *TableValuedFunctionPlan) Build() error

func (*TableValuedFunctionPlan) String

func (plan *TableValuedFunctionPlan) String() string

func (*TableValuedFunctionPlan) Walk

func (plan *TableValuedFunctionPlan) Walk(visit Visit) error

type UnaryExpressionPlan

type UnaryExpressionPlan struct {
	Name     string
	FuncName string
	Expr     IPlan
}

func NewUnaryExpressionPlan

func NewUnaryExpressionPlan(funcName string, expr IPlan) *UnaryExpressionPlan

func (*UnaryExpressionPlan) Build

func (plan *UnaryExpressionPlan) Build() error

func (*UnaryExpressionPlan) String

func (plan *UnaryExpressionPlan) String() string

func (*UnaryExpressionPlan) Walk

func (plan *UnaryExpressionPlan) Walk(visit Visit) error

type UsePlan

type UsePlan struct {
	Name string
	Ast  *sqlparser.Use
}

func (*UsePlan) Build

func (plan *UsePlan) Build() error

func (*UsePlan) String

func (plan *UsePlan) String() string

func (*UsePlan) Walk

func (plan *UsePlan) Walk(visit Visit) error

type VariablePlan

type VariablePlan struct {
	Name  string
	Value string
}

func NewVariablePlan

func NewVariablePlan(value string) *VariablePlan

func (*VariablePlan) Build

func (plan *VariablePlan) Build() error

func (*VariablePlan) String

func (plan *VariablePlan) String() string

func (*VariablePlan) Walk

func (plan *VariablePlan) Walk(visit Visit) error

type Visit

type Visit func(plan IPlan) (kontinue bool, err error)

Jump to

Keyboard shortcuts

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