Documentation
¶
Overview ¶
Package operators contains the operators used to plan queries.
The operators go through a few phases while planning:
- Initial plan In this first pass, we build an operator tree from the incoming parsed query. At the leaves, it will contain QueryGraphs - these are the tables in the FROM clause that we can easily do join ordering on because they are all inner joins. All the post-processing - aggregations, sorting, limit etc. are at this stage contained in Horizon structs. We try to push these down under routes, and expand the ones that can't be pushed down into individual operators such as Projection, Aggregation, Limit, etc.
- Planning Once the initial plan has been fully built, we go through a number of phases. recursively running rewriters on the tree in a fixed point fashion, until we've gone over all phases and the tree has stop changing.
- Offset planning Now is the time to stop working with AST objects and transform remaining expressions being used on top of vtgate to either offsets on inputs or evalengine expressions.
Package operators contains the operators used to plan queries.
The operators go through a few phases while planning:
- Initial plan In this first pass, we build an operator tree from the incoming parsed query. At the leaves, it will contain QueryGraphs - these are the tables in the FROM clause that we can easily do join ordering on because they are all inner joins. All the post-processing - aggregations, sorting, limit etc. are at this stage contained in Horizon structs. We try to push these down under routes, and expand the ones that can't be pushed down into individual operators such as Projection, Agreggation, Limit, etc.
- Planning Once the initial plan has been fully built, we go through a number of phases. recursively running rewriters on the tree in a fixed point fashion, until we've gone over all phases and the tree has stop changing.
- Offset planning Now is the time to stop working with AST objects and transform remaining expressions being used on top of vtgate to either offsets on inputs or evalengine expressions.
Index ¶
- Constants
- Variables
- func CompareRefInt(a *int, b *int) bool
- func ContainsAggr(ctx *plancontext.PlanningContext, e sqlparser.SQLNode) (hasAggr bool)
- func CostOf(op Operator) (cost int)
- func EnableDebugPrinting() (reset func())
- func FromLeftOffset(i int) int
- func FromRightOffset(i int) int
- func IsAggr(ctx *plancontext.PlanningContext, e sqlparser.SQLNode) bool
- func IsOuter(outer JoinOp) bool
- func IsTableSchemaOrName(e sqlparser.Expr, version string) (col *sqlparser.ColName, isTableSchema bool, isTableName bool)
- func NotImplementedSchemaInfoResolver(*sqlparser.ColName) (int, error)
- func PanicHandler(err *error)
- func QualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) string
- func QualifiedString(ks *vindexes.Keyspace, s string) string
- func QualifiedTableName(ks *vindexes.Keyspace, t sqlparser.TableName) string
- func QualifiedTableNames(ks *vindexes.Keyspace, ts []sqlparser.TableName) []string
- func QualifiedTables(ks *vindexes.Keyspace, vts []*vindexes.Table) []string
- func SingleQualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) []string
- func SingleQualifiedString(ks *vindexes.Keyspace, s string) []string
- func SortGrouping(a []GroupBy)
- func Swap(parent, child Operator, message string) (Operator, *ApplyResult)
- func TableID(op Operator) (result semantics.TableSet)
- func TablesUsed(op Operator) []string
- func ToLeftOffset(i int) int
- func ToRightOffset(i int) int
- func ToTree(op Operator) string
- func Visit(root Operator, visitor func(Operator) error) error
- type Aggr
- type Aggregator
- func (a *Aggregator) AddColumn(ctx *plancontext.PlanningContext, reuse bool, groupBy bool, ...) int
- func (a *Aggregator) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (a *Aggregator) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (a *Aggregator) Clone(inputs []Operator) Operator
- func (a *Aggregator) FindCol(ctx *plancontext.PlanningContext, in sqlparser.Expr, underRoute bool) int
- func (a *Aggregator) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (a *Aggregator) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (a *Aggregator) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (a *Aggregator) Inputs() []Operator
- func (a *Aggregator) SetInputs(operators []Operator)
- func (a *Aggregator) ShortDescription() string
- func (a *Aggregator) SplitAggregatorBelowOperators(ctx *plancontext.PlanningContext, input []Operator) *Aggregator
- type AliasedProjections
- type AnyShardRouting
- func (rr *AnyShardRouting) AlternateInKeyspace(keyspace *vindexes.Keyspace) *Route
- func (rr *AnyShardRouting) Clone() Routing
- func (rr *AnyShardRouting) Cost() int
- func (rr *AnyShardRouting) Keyspace() *vindexes.Keyspace
- func (rr *AnyShardRouting) OpCode() engine.Opcode
- func (rr *AnyShardRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
- type ApplyJoin
- func (aj *ApplyJoin) AddColumn(ctx *plancontext.PlanningContext, reuse bool, groupBy bool, ...) int
- func (aj *ApplyJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
- func (aj *ApplyJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (aj *ApplyJoin) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (aj *ApplyJoin) Clone(inputs []Operator) Operator
- func (aj *ApplyJoin) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
- func (aj *ApplyJoin) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (aj *ApplyJoin) GetLHS() Operator
- func (aj *ApplyJoin) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (aj *ApplyJoin) GetRHS() Operator
- func (aj *ApplyJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (aj *ApplyJoin) Inputs() []Operator
- func (aj *ApplyJoin) IsInner() bool
- func (a *ApplyJoin) LHSColumnsNeeded(ctx *plancontext.PlanningContext) (needed sqlparser.Exprs)
- func (aj *ApplyJoin) MakeInner()
- func (aj *ApplyJoin) SetInputs(inputs []Operator)
- func (aj *ApplyJoin) SetLHS(operator Operator)
- func (aj *ApplyJoin) SetRHS(operator Operator)
- func (aj *ApplyJoin) ShortDescription() string
- type ApplyResult
- type BindVarExpr
- type ColNameColumns
- type Comparison
- type Cost
- type DMLCommon
- type DMLWithInput
- func (DMLWithInput) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (DMLWithInput) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (DMLWithInput) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (d *DMLWithInput) Clone(inputs []Operator) Operator
- func (DMLWithInput) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (DMLWithInput) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (d *DMLWithInput) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (DMLWithInput) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (d *DMLWithInput) Inputs() []Operator
- func (d *DMLWithInput) SetInputs(inputs []Operator)
- func (d *DMLWithInput) ShortDescription() string
- type Delete
- func (Delete) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (Delete) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (Delete) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (d *Delete) Clone(inputs []Operator) Operator
- func (Delete) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Delete) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (d *Delete) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (Delete) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (d *Delete) Inputs() []Operator
- func (d *Delete) SetInputs(inputs []Operator)
- func (d *Delete) ShortDescription() string
- func (d *Delete) TablesUsed() []string
- type DerivedTable
- type Distinct
- func (d *Distinct) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (d *Distinct) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (d *Distinct) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (d *Distinct) Clone(inputs []Operator) Operator
- func (d *Distinct) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (d *Distinct) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (d *Distinct) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (d *Distinct) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (d *Distinct) Inputs() []Operator
- func (d *Distinct) SetInputs(operators []Operator)
- func (d *Distinct) ShortDescription() string
- type DualRouting
- type EvalEngine
- type ExprInfo
- type Filter
- func (f *Filter) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (f *Filter) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (f *Filter) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (f *Filter) Clone(inputs []Operator) Operator
- func (f *Filter) Compact(*plancontext.PlanningContext) (Operator, *ApplyResult)
- func (f *Filter) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (f *Filter) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (f *Filter) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (f *Filter) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (f *Filter) Inputs() []Operator
- func (f *Filter) SetInputs(ops []Operator)
- func (f *Filter) ShortDescription() string
- func (f *Filter) UnsolvedPredicates(st *semantics.SemTable) []sqlparser.Expr
- type FkCascade
- func (FkCascade) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (FkCascade) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (FkCascade) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (fkc *FkCascade) Clone(inputs []Operator) Operator
- func (FkCascade) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (FkCascade) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (fkc *FkCascade) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (FkCascade) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (fkc *FkCascade) Inputs() []Operator
- func (fkc *FkCascade) SetInputs(operators []Operator)
- func (fkc *FkCascade) ShortDescription() string
- type FkChild
- func (FkChild) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (FkChild) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (FkChild) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (FkChild) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (FkChild) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (FkChild) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- type FkVerify
- func (FkVerify) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (FkVerify) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (FkVerify) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (fkv *FkVerify) Clone(inputs []Operator) Operator
- func (FkVerify) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (FkVerify) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (fkv *FkVerify) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (FkVerify) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (fkv *FkVerify) Inputs() []Operator
- func (fkv *FkVerify) SetInputs(operators []Operator)
- func (fkv *FkVerify) ShortDescription() string
- type FromStatement
- type Generate
- type GroupBy
- type HashJoin
- func (hj *HashJoin) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, ...) int
- func (hj *HashJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
- func (hj *HashJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (hj *HashJoin) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (hj *HashJoin) Clone(inputs []Operator) Operator
- func (hj *HashJoin) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
- func (hj *HashJoin) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (hj *HashJoin) GetLHS() Operator
- func (hj *HashJoin) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (hj *HashJoin) GetRHS() Operator
- func (hj *HashJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (hj *HashJoin) Inputs() []Operator
- func (hj *HashJoin) IsInner() bool
- func (hj *HashJoin) JoinPredicate() sqlparser.Expr
- func (hj *HashJoin) MakeInner()
- func (hj *HashJoin) SetInputs(operators []Operator)
- func (hj *HashJoin) SetLHS(op Operator)
- func (hj *HashJoin) SetRHS(op Operator)
- func (hj *HashJoin) ShortDescription() string
- type Horizon
- func (h *Horizon) AddColumn(ctx *plancontext.PlanningContext, reuse bool, _ bool, ...) int
- func (h *Horizon) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (h *Horizon) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (h *Horizon) Clone(inputs []Operator) Operator
- func (h *Horizon) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (h *Horizon) GetColumns(ctx *plancontext.PlanningContext) (exprs []*sqlparser.AliasedExpr)
- func (h *Horizon) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (h *Horizon) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (h *Horizon) Inputs() []Operator
- func (h *Horizon) IsDerived() bool
- func (h *Horizon) IsMergeable(ctx *plancontext.PlanningContext) bool
- func (h *Horizon) SetInputs(ops []Operator)
- func (h *Horizon) ShortDescription() string
- type InfoSchemaRouting
- func (isr *InfoSchemaRouting) Clone() Routing
- func (isr *InfoSchemaRouting) Cost() int
- func (isr *InfoSchemaRouting) Keyspace() *vindexes.Keyspace
- func (isr *InfoSchemaRouting) OpCode() engine.Opcode
- func (isr *InfoSchemaRouting) UpdateRoutingParams(ctx *plancontext.PlanningContext, rp *engine.RoutingParameters)
- type Insert
- func (Insert) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (Insert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (Insert) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (i *Insert) Clone([]Operator) Operator
- func (Insert) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Insert) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (i *Insert) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (Insert) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (Insert) Inputs() []Operator
- func (Insert) SetInputs(ops []Operator)
- func (i *Insert) ShortDescription() string
- func (i *Insert) Statement() sqlparser.Statement
- func (i *Insert) TablesUsed() []string
- type InsertSelection
- func (InsertSelection) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (InsertSelection) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (InsertSelection) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (is *InsertSelection) Clone(inputs []Operator) Operator
- func (InsertSelection) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (InsertSelection) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (is *InsertSelection) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (InsertSelection) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (is *InsertSelection) Inputs() []Operator
- func (is *InsertSelection) SetInputs(inputs []Operator)
- func (is *InsertSelection) ShortDescription() string
- type Join
- func (Join) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (j *Join) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
- func (j *Join) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (Join) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (j *Join) Clone(inputs []Operator) Operator
- func (j *Join) Compact(ctx *plancontext.PlanningContext) (Operator, *ApplyResult)
- func (Join) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Join) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (j *Join) GetLHS() Operator
- func (j *Join) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (j *Join) GetRHS() Operator
- func (Join) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (j *Join) Inputs() []Operator
- func (j *Join) IsInner() bool
- func (j *Join) MakeInner()
- func (j *Join) SetInputs(ops []Operator)
- func (j *Join) SetLHS(operator Operator)
- func (j *Join) SetRHS(operator Operator)
- func (j *Join) ShortDescription() string
- type JoinOp
- type Limit
- func (l *Limit) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (l *Limit) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (l *Limit) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (l *Limit) Clone(inputs []Operator) Operator
- func (l *Limit) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (l *Limit) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (l *Limit) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (l *Limit) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (l *Limit) Inputs() []Operator
- func (l *Limit) SetInputs(operators []Operator)
- func (l *Limit) ShortDescription() string
- type LockAndComment
- func (l *LockAndComment) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, ...) int
- func (l *LockAndComment) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (l *LockAndComment) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (l *LockAndComment) Clone(inputs []Operator) Operator
- func (l *LockAndComment) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (l *LockAndComment) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (l *LockAndComment) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (l *LockAndComment) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (l *LockAndComment) Inputs() []Operator
- func (l *LockAndComment) SetInputs(operators []Operator)
- func (l *LockAndComment) ShortDescription() string
- type NoneRouting
- type Offset
- type OpWithAST
- type Operator
- func AddPredicate(ctx *plancontext.PlanningContext, join JoinOp, expr sqlparser.Expr, ...) Operator
- func BottomUp(root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, ...) Operator
- func Clone(op Operator) Operator
- func FixedPointBottomUp(root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, ...) (op Operator)
- func PlanQuery(ctx *plancontext.PlanningContext, stmt sqlparser.Statement) (result Operator, err error)
- func ToSQL(ctx *plancontext.PlanningContext, op Operator) (_ sqlparser.Statement, _ Operator, err error)
- func TopDown(root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, ...) Operator
- type OrderBy
- type Ordering
- func (o *Ordering) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (o *Ordering) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (o *Ordering) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (o *Ordering) Clone(inputs []Operator) Operator
- func (o *Ordering) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (o *Ordering) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (o *Ordering) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (o *Ordering) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (o *Ordering) Inputs() []Operator
- func (o *Ordering) SetInputs(operators []Operator)
- func (o *Ordering) ShortDescription() string
- type Phase
- type ProjCols
- type ProjExpr
- type Projection
- func (p *Projection) AddColumn(ctx *plancontext.PlanningContext, reuse bool, addToGroupBy bool, ...) int
- func (p *Projection) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (p *Projection) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (p *Projection) AllOffsets() (cols []int, colNames []string)
- func (p *Projection) Clone(inputs []Operator) Operator
- func (p *Projection) Compact(ctx *plancontext.PlanningContext) (Operator, *ApplyResult)
- func (p *Projection) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (p *Projection) GetAliasedProjections() (AliasedProjections, error)
- func (p *Projection) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (p *Projection) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (p *Projection) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (p *Projection) Inputs() []Operator
- func (p *Projection) SetInputs(operators []Operator)
- func (p *Projection) ShortDescription() string
- type QueryGraph
- func (QueryGraph) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (qg *QueryGraph) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (QueryGraph) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (qg *QueryGraph) Clone([]Operator) Operator
- func (QueryGraph) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (QueryGraph) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (qg *QueryGraph) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (qg *QueryGraph) GetPredicates(lhs, rhs semantics.TableSet) []sqlparser.Expr
- func (QueryGraph) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (QueryGraph) Inputs() []Operator
- func (QueryGraph) SetInputs(ops []Operator)
- func (qg *QueryGraph) ShortDescription() string
- func (qg *QueryGraph) UnsolvedPredicates(_ *semantics.SemTable) []sqlparser.Expr
- type QueryProjection
- func (qp *QueryProjection) AddGroupBy(by GroupBy)
- func (qp *QueryProjection) AggregationExpressions(ctx *plancontext.PlanningContext, allowComplexExpression bool) (out []Aggr, complex bool)
- func (qp *QueryProjection) AlignGroupByAndOrderBy(ctx *plancontext.PlanningContext) bool
- func (qp *QueryProjection) FindSelectExprIndexForExpr(ctx *plancontext.PlanningContext, expr sqlparser.Expr) *int
- func (qp *QueryProjection) GetColumnCount() int
- func (qp *QueryProjection) GetGrouping() []GroupBy
- func (qp *QueryProjection) NeedsAggregation() bool
- func (qp *QueryProjection) NeedsDistinct() bool
- func (qp *QueryProjection) OldAlignGroupByAndOrderBy(ctx *plancontext.PlanningContext)
- type QueryTable
- type Rewrite
- type Route
- func (r *Route) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (r *Route) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (r *Route) AddWSColumn(ctx *plancontext.PlanningContext, offset int, _ bool) int
- func (r *Route) Clone(inputs []Operator) Operator
- func (r *Route) Cost() int
- func (r *Route) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
- func (r *Route) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (r *Route) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (r *Route) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (r *Route) Inputs() []Operator
- func (r *Route) IsSingleShard() bool
- func (r *Route) IsSingleShardOrByDestination() bool
- func (r *Route) SetInputs(ops []Operator)
- func (r *Route) ShortDescription() string
- func (r *Route) TablesUsed() []string
- type RouteOrdering
- type Routing
- type SelectExpr
- type SequenceRouting
- type Sequential
- func (Sequential) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (Sequential) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (Sequential) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (s *Sequential) Clone(inputs []Operator) Operator
- func (Sequential) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Sequential) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (s *Sequential) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (Sequential) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (s *Sequential) Inputs() []Operator
- func (s *Sequential) SetInputs(ops []Operator)
- func (s *Sequential) ShortDescription() string
- type SetExpr
- type ShardedRouting
- func (tr *ShardedRouting) Clone() Routing
- func (tr *ShardedRouting) Cost() int
- func (tr *ShardedRouting) Keyspace() *vindexes.Keyspace
- func (tr *ShardedRouting) OpCode() engine.Opcode
- func (tr *ShardedRouting) PickBestAvailableVindex()
- func (tr *ShardedRouting) SelectedVindex() vindexes.Vindex
- func (tr *ShardedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
- func (tr *ShardedRouting) VindexExpressions() []sqlparser.Expr
- type ShouldVisit
- type StarProjections
- type SubQuery
- func (sq *SubQuery) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, ...) int
- func (sq *SubQuery) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (sq *SubQuery) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (sq *SubQuery) Clone(inputs []Operator) Operator
- func (sq *SubQuery) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (sq *SubQuery) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (sq *SubQuery) GetJoinColumns(ctx *plancontext.PlanningContext, outer Operator) ([]applyJoinColumn, error)
- func (sq *SubQuery) GetMergePredicates() []sqlparser.Expr
- func (sq *SubQuery) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (sq *SubQuery) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (sq *SubQuery) Inputs() []Operator
- func (sq *SubQuery) OuterExpressionsNeeded(ctx *plancontext.PlanningContext, outer Operator) (result []*sqlparser.ColName)
- func (sq *SubQuery) SetInputs(inputs []Operator)
- func (sq *SubQuery) ShortDescription() string
- type SubQueryBuilder
- type SubQueryContainer
- func (sqc *SubQueryContainer) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, ...) int
- func (sqc *SubQueryContainer) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (sqc *SubQueryContainer) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (sqc *SubQueryContainer) Clone(inputs []Operator) Operator
- func (sqc *SubQueryContainer) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (sqc *SubQueryContainer) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (sqc *SubQueryContainer) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (sqc *SubQueryContainer) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (sqc *SubQueryContainer) Inputs() []Operator
- func (sqc *SubQueryContainer) SetInputs(ops []Operator)
- func (sqc *SubQueryContainer) ShortDescription() string
- type SubQueryExpression
- type Table
- func (to *Table) AddCol(col *sqlparser.ColName)
- func (to *Table) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (to *Table) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (*Table) AddWSColumn(*plancontext.PlanningContext, int, bool) int
- func (to *Table) Clone([]Operator) Operator
- func (to *Table) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (to *Table) GetColNames() []*sqlparser.ColName
- func (to *Table) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (to *Table) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (to *Table) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (Table) Inputs() []Operator
- func (Table) SetInputs(ops []Operator)
- func (to *Table) ShortDescription() string
- func (to *Table) TablesUsed() []string
- type TableUser
- type TargetTable
- type TargetedRouting
- type Union
- func (u *Union) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (u *Union) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (u *Union) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (u *Union) Clone(inputs []Operator) Operator
- func (u *Union) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (u *Union) GetColumns(ctx *plancontext.PlanningContext) (result []*sqlparser.AliasedExpr)
- func (u *Union) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (u *Union) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (u *Union) GetSelectFor(source int) *sqlparser.Select
- func (u *Union) Inputs() []Operator
- func (u *Union) NoLHSTableSet()
- func (u *Union) SetInputs(ops []Operator)
- func (u *Union) ShortDescription() string
- type Update
- func (Update) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (Update) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (Update) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (u *Update) Clone(inputs []Operator) Operator
- func (Update) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Update) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (u *Update) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (Update) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (u *Update) Inputs() []Operator
- func (u *Update) SetInputs(inputs []Operator)
- func (u *Update) ShortDescription() string
- func (u *Update) TablesUsed() []string
- type Upsert
- func (Upsert) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
- func (Upsert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
- func (Upsert) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
- func (u *Upsert) Clone(inputs []Operator) Operator
- func (Upsert) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
- func (Upsert) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (u *Upsert) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
- func (Upsert) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
- func (u *Upsert) Inputs() []Operator
- func (u *Upsert) SetInputs(inputs []Operator)
- func (u *Upsert) ShortDescription() string
- type UpsertSource
- type VerifyOp
- type Vindex
- func (v *Vindex) AddCol(col *sqlparser.ColName)
- func (v *Vindex) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ...) int
- func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
- func (*Vindex) AddWSColumn(*plancontext.PlanningContext, int, bool) int
- func (v *Vindex) CheckValid()
- func (v *Vindex) Clone([]Operator) Operator
- func (v *Vindex) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
- func (v *Vindex) GetColNames() []*sqlparser.ColName
- func (v *Vindex) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
- func (v *Vindex) GetOrdering(*plancontext.PlanningContext) []OrderBy
- func (v *Vindex) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
- func (Vindex) Inputs() []Operator
- func (Vindex) SetInputs(ops []Operator)
- func (v *Vindex) ShortDescription() string
- func (v *Vindex) TablesUsed() []string
- type VindexOption
- type VindexPlusPredicates
- type VindexTable
- type VisitF
- type VisitRule
Constants ¶
const ( Unknown joinSide = iota Left Right )
Variables ¶
var DebugOperatorTree = false
Functions ¶
func CompareRefInt ¶
CompareRefInt compares two references of integers. In case either one is nil, it is considered to be smaller
func ContainsAggr ¶
func ContainsAggr(ctx *plancontext.PlanningContext, e sqlparser.SQLNode) (hasAggr bool)
func EnableDebugPrinting ¶
func EnableDebugPrinting() (reset func())
func FromLeftOffset ¶
func FromRightOffset ¶
func IsAggr ¶
func IsAggr(ctx *plancontext.PlanningContext, e sqlparser.SQLNode) bool
func IsTableSchemaOrName ¶
func PanicHandler ¶
func PanicHandler(err *error)
func QualifiedIdentifier ¶
func QualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) string
func QualifiedTableName ¶
func QualifiedTableNames ¶
func SingleQualifiedIdentifier ¶
func SingleQualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) []string
func SortGrouping ¶
func SortGrouping(a []GroupBy)
func Swap ¶
func Swap(parent, child Operator, message string) (Operator, *ApplyResult)
Swap takes a tree like a->b->c and swaps `a` and `b`, so we end up with b->a->c
func TablesUsed ¶
func ToLeftOffset ¶
func ToRightOffset ¶
Types ¶
type Aggr ¶
type Aggr struct { Original *sqlparser.AliasedExpr Func sqlparser.AggrFunc // if we are missing a Func, it means this is a AggregateAnyValue OpCode opcode.AggregateOpcode // OriginalOpCode will contain opcode.AggregateUnassigned unless we are changing opcode while pushing them down OriginalOpCode opcode.AggregateOpcode Alias string // The index at which the user expects to see this aggregated function. Set to nil, if the user does not ask for it // Only used in the old Horizon Planner Index *int Distinct bool // the offsets point to columns on the same aggregator ColOffset int WSOffset int SubQueryExpression []*SubQuery }
Aggr encodes all information needed for aggregation functions
func NewAggr ¶
func NewAggr(opCode opcode.AggregateOpcode, f sqlparser.AggrFunc, original *sqlparser.AliasedExpr, alias string) Aggr
func (Aggr) GetTypeCollation ¶
func (aggr Aggr) GetTypeCollation(ctx *plancontext.PlanningContext) evalengine.Type
func (Aggr) NeedsWeightString ¶
func (aggr Aggr) NeedsWeightString(ctx *plancontext.PlanningContext) bool
type Aggregator ¶
type Aggregator struct { Source Operator Columns []*sqlparser.AliasedExpr WithRollup bool Grouping []GroupBy Aggregations []Aggr // We support a single distinct aggregation per aggregator. It is stored here. // When planning the ordering that the OrderedAggregate will require, // this needs to be the last ORDER BY expression DistinctExpr sqlparser.Expr // Pushed will be set to true once this aggregation has been pushed deeper in the tree Pushed bool // Original will only be true for the original aggregator created from the AST Original bool ResultColumns int QP *QueryProjection DT *DerivedTable // contains filtered or unexported fields }
Aggregator represents a GroupBy γ relational operator. Both all aggregations and no grouping, and the inverse of all grouping and no aggregations are valid configurations of this operator
func (*Aggregator) AddColumn ¶
func (a *Aggregator) AddColumn(ctx *plancontext.PlanningContext, reuse bool, groupBy bool, ae *sqlparser.AliasedExpr) int
func (*Aggregator) AddPredicate ¶
func (a *Aggregator) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Aggregator) AddWSColumn ¶
func (a *Aggregator) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Aggregator) Clone ¶
func (a *Aggregator) Clone(inputs []Operator) Operator
func (*Aggregator) FindCol ¶
func (a *Aggregator) FindCol(ctx *plancontext.PlanningContext, in sqlparser.Expr, underRoute bool) int
func (*Aggregator) GetColumns ¶
func (a *Aggregator) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Aggregator) GetOrdering ¶
func (a *Aggregator) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Aggregator) GetSelectExprs ¶
func (a *Aggregator) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Aggregator) Inputs ¶
func (a *Aggregator) Inputs() []Operator
func (*Aggregator) SetInputs ¶
func (a *Aggregator) SetInputs(operators []Operator)
func (*Aggregator) ShortDescription ¶
func (a *Aggregator) ShortDescription() string
func (*Aggregator) SplitAggregatorBelowOperators ¶
func (a *Aggregator) SplitAggregatorBelowOperators(ctx *plancontext.PlanningContext, input []Operator) *Aggregator
SplitAggregatorBelowOperators returns the aggregator that will live under the Route. This is used when we are splitting the aggregation so one part is done at the mysql level and one part at the vtgate level
type AliasedProjections ¶
type AliasedProjections []*ProjExpr
Used when we know all the columns
func (AliasedProjections) GetColumns ¶
func (ap AliasedProjections) GetColumns() []*sqlparser.AliasedExpr
func (AliasedProjections) GetSelectExprs ¶
func (ap AliasedProjections) GetSelectExprs() sqlparser.SelectExprs
type AnyShardRouting ¶
type AnyShardRouting struct { Alternates map[*vindexes.Keyspace]*Route // contains filtered or unexported fields }
AnyShardRouting is used for routing logic where any shard in the keyspace can be used. Shared by unsharded and reference routing
func (*AnyShardRouting) AlternateInKeyspace ¶
func (rr *AnyShardRouting) AlternateInKeyspace(keyspace *vindexes.Keyspace) *Route
func (*AnyShardRouting) Clone ¶
func (rr *AnyShardRouting) Clone() Routing
func (*AnyShardRouting) Cost ¶
func (rr *AnyShardRouting) Cost() int
func (*AnyShardRouting) Keyspace ¶
func (rr *AnyShardRouting) Keyspace() *vindexes.Keyspace
func (*AnyShardRouting) OpCode ¶
func (rr *AnyShardRouting) OpCode() engine.Opcode
func (*AnyShardRouting) UpdateRoutingParams ¶
func (rr *AnyShardRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
type ApplyJoin ¶
type ApplyJoin struct {
LHS, RHS Operator
// JoinType is permitted to store only 3 of the possible values
// NormalJoinType, StraightJoinType and LeftJoinType.
JoinType sqlparser.JoinType
// LeftJoin will be true in the case of an outer join
LeftJoin bool
// JoinColumns keeps track of what AST expression is represented in the Columns array
JoinColumns *applyJoinColumns
// JoinPredicates are join predicates that have been broken up into left hand side and right hand side parts.
JoinPredicates *applyJoinColumns
// ExtraVars are columns we need to copy from left to right not needed by any predicates or projections,
// these are needed by other operators further down the right hand side of the join
ExtraLHSVars []BindVarExpr
// Columns stores the column indexes of the columns coming from the left and right side
// negative value comes from LHS and positive from RHS
Columns []int
// Vars are the arguments that need to be copied from the LHS to the RHS
Vars map[string]int
}
ApplyJoin is a nested loop join - for each row on the LHS, we'll execute the plan on the RHS, feeding data from left to right
func NewApplyJoin ¶
func NewApplyJoin(ctx *plancontext.PlanningContext, lhs, rhs Operator, predicate sqlparser.Expr, joinType sqlparser.JoinType) *ApplyJoin
func (*ApplyJoin) AddColumn ¶
func (aj *ApplyJoin) AddColumn( ctx *plancontext.PlanningContext, reuse bool, groupBy bool, expr *sqlparser.AliasedExpr, ) int
func (*ApplyJoin) AddJoinPredicate ¶
func (aj *ApplyJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
func (*ApplyJoin) AddPredicate ¶
func (aj *ApplyJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*ApplyJoin) AddWSColumn ¶
func (aj *ApplyJoin) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*ApplyJoin) FindCol ¶
func (aj *ApplyJoin) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
func (*ApplyJoin) GetColumns ¶
func (aj *ApplyJoin) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*ApplyJoin) GetOrdering ¶
func (aj *ApplyJoin) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*ApplyJoin) GetSelectExprs ¶
func (aj *ApplyJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*ApplyJoin) LHSColumnsNeeded ¶
func (a *ApplyJoin) LHSColumnsNeeded(ctx *plancontext.PlanningContext) (needed sqlparser.Exprs)
func (*ApplyJoin) ShortDescription ¶
type ApplyResult ¶
type ApplyResult struct {
Transformations []Rewrite
}
ApplyResult tracks modifications to node and expression trees. Only return SameTree when it is acceptable to return the original input and discard the returned result as a performance improvement.
var (
NoRewrite *ApplyResult = nil
)
func Rewrote ¶
func Rewrote(message string) *ApplyResult
func (*ApplyResult) Changed ¶
func (ar *ApplyResult) Changed() bool
func (*ApplyResult) Merge ¶
func (ar *ApplyResult) Merge(other *ApplyResult) *ApplyResult
type BindVarExpr ¶
BindVarExpr is an expression needed from one side of a join/subquery, and the argument name for it. TODO: Do we really need to store the name here? it could be found in the semantic state instead
func (BindVarExpr) String ¶
func (bve BindVarExpr) String() string
type ColNameColumns ¶
type Comparison ¶
func (Comparison) String ¶
func (c Comparison) String() string
type DMLWithInput ¶
type DMLWithInput struct { Source Operator DML []Operator Offsets [][]int BvList []map[string]int // contains filtered or unexported fields }
DMLWithInput is used to represent a DML Operator taking input from a Source Operator
func (DMLWithInput) AddColumn ¶
func (DMLWithInput) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (DMLWithInput) AddPredicate ¶
func (DMLWithInput) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (DMLWithInput) AddWSColumn ¶
func (DMLWithInput) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*DMLWithInput) Clone ¶
func (d *DMLWithInput) Clone(inputs []Operator) Operator
func (DMLWithInput) FindCol ¶
func (DMLWithInput) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (DMLWithInput) GetColumns ¶
func (DMLWithInput) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*DMLWithInput) GetOrdering ¶
func (d *DMLWithInput) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (DMLWithInput) GetSelectExprs ¶
func (DMLWithInput) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*DMLWithInput) Inputs ¶
func (d *DMLWithInput) Inputs() []Operator
func (*DMLWithInput) SetInputs ¶
func (d *DMLWithInput) SetInputs(inputs []Operator)
func (*DMLWithInput) ShortDescription ¶
func (d *DMLWithInput) ShortDescription() string
type Delete ¶
type Delete struct { *DMLCommon // contains filtered or unexported fields }
func (Delete) AddColumn ¶
func (Delete) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (Delete) AddPredicate ¶
func (Delete) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (Delete) AddWSColumn ¶
func (Delete) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (Delete) FindCol ¶
func (Delete) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Delete) GetColumns ¶
func (Delete) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Delete) GetOrdering ¶
func (d *Delete) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (Delete) GetSelectExprs ¶
func (Delete) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Delete) ShortDescription ¶
func (*Delete) TablesUsed ¶
type DerivedTable ¶
func (*DerivedTable) RewriteExpression ¶
func (dt *DerivedTable) RewriteExpression(ctx *plancontext.PlanningContext, expr sqlparser.Expr) sqlparser.Expr
func (*DerivedTable) String ¶
func (dt *DerivedTable) String() string
type Distinct ¶
type Distinct struct { Source Operator QP *QueryProjection // When we go from AST to operator, we place DISTINCT ops in the required places in the op tree // These are marked as `Required`, because they are semantically important to the results of the query. // During planning, when we can't push down the DISTINCT op any further, we sometimes create and push down // additional DISTINCT ops that are not strictly required, but that limit the number of incoming rows so less // work has to be done. When we have pushed down these performance DISTINCTs, we set the `PushedPerformance` // field to true on the originating op Required bool PushedPerformance bool // This is only filled in during offset planning Columns []engine.CheckCol Truncate int }
func (*Distinct) AddColumn ¶
func (d *Distinct) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Distinct) AddPredicate ¶
func (d *Distinct) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Distinct) AddWSColumn ¶
func (d *Distinct) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Distinct) FindCol ¶
func (d *Distinct) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Distinct) GetColumns ¶
func (d *Distinct) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Distinct) GetOrdering ¶
func (d *Distinct) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Distinct) GetSelectExprs ¶
func (d *Distinct) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Distinct) ShortDescription ¶
type DualRouting ¶
type DualRouting struct{}
DualRouting represents the dual-table. It is special compared to all other tables because it can be merged with tables in any keyspace
func (*DualRouting) Clone ¶
func (dr *DualRouting) Clone() Routing
func (*DualRouting) Cost ¶
func (dr *DualRouting) Cost() int
func (*DualRouting) Keyspace ¶
func (dr *DualRouting) Keyspace() *vindexes.Keyspace
func (*DualRouting) OpCode ¶
func (dr *DualRouting) OpCode() engine.Opcode
func (*DualRouting) UpdateRoutingParams ¶
func (dr *DualRouting) UpdateRoutingParams(*plancontext.PlanningContext, *engine.RoutingParameters)
type EvalEngine ¶
type EvalEngine struct {
EExpr evalengine.Expr
}
EvalEngine is used for expressions that have to be evaluated in the vtgate using the evalengine
type Filter ¶
type Filter struct { Source Operator Predicates []sqlparser.Expr // PredicateWithOffsets is the evalengine expression that will finally be used. // It contains the ANDed predicates in Predicates, with ColName:s replaced by Offset:s PredicateWithOffsets evalengine.Expr Truncate int }
func (*Filter) AddColumn ¶
func (f *Filter) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Filter) AddPredicate ¶
func (f *Filter) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Filter) AddWSColumn ¶
func (f *Filter) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Filter) Compact ¶
func (f *Filter) Compact(*plancontext.PlanningContext) (Operator, *ApplyResult)
func (*Filter) FindCol ¶
func (f *Filter) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Filter) GetColumns ¶
func (f *Filter) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Filter) GetOrdering ¶
func (f *Filter) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Filter) GetSelectExprs ¶
func (f *Filter) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Filter) ShortDescription ¶
type FkCascade ¶
type FkCascade struct { Selection Operator Children []*FkChild Parent Operator // contains filtered or unexported fields }
FkCascade is used to represent a foreign key cascade operation as an operator. This operator is created for DML queries that require cascades (for example, ON DELETE CASCADE).
func (FkCascade) AddColumn ¶
func (FkCascade) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (FkCascade) AddPredicate ¶
func (FkCascade) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (FkCascade) AddWSColumn ¶
func (FkCascade) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (FkCascade) FindCol ¶
func (FkCascade) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (FkCascade) GetColumns ¶
func (FkCascade) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*FkCascade) GetOrdering ¶
func (fkc *FkCascade) GetOrdering(*plancontext.PlanningContext) []OrderBy
GetOrdering implements the Operator interface
func (FkCascade) GetSelectExprs ¶
func (FkCascade) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*FkCascade) ShortDescription ¶
ShortDescription implements the Operator interface
type FkChild ¶
type FkChild struct { BVName string Cols []int // indexes NonLiteralInfo []engine.NonLiteralUpdateInfo Op Operator // contains filtered or unexported fields }
FkChild is used to represent a foreign key child table operation
func (FkChild) AddColumn ¶
func (FkChild) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (FkChild) AddPredicate ¶
func (FkChild) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (FkChild) AddWSColumn ¶
func (FkChild) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (FkChild) FindCol ¶
func (FkChild) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (FkChild) GetColumns ¶
func (FkChild) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (FkChild) GetSelectExprs ¶
func (FkChild) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
type FkVerify ¶
type FkVerify struct { Verify []*VerifyOp Input Operator // contains filtered or unexported fields }
FkVerify is used to represent a foreign key verification operation as an operator. This operator is created for DML queries that require verifications on the existence of the rows in the parent table (for example, INSERT and UPDATE).
func (FkVerify) AddColumn ¶
func (FkVerify) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (FkVerify) AddPredicate ¶
func (FkVerify) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (FkVerify) AddWSColumn ¶
func (FkVerify) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (FkVerify) FindCol ¶
func (FkVerify) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (FkVerify) GetColumns ¶
func (FkVerify) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*FkVerify) GetOrdering ¶
func (fkv *FkVerify) GetOrdering(*plancontext.PlanningContext) []OrderBy
GetOrdering implements the Operator interface
func (FkVerify) GetSelectExprs ¶
func (FkVerify) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*FkVerify) ShortDescription ¶
ShortDescription implements the Operator interface
type FromStatement ¶
type Generate ¶
type Generate struct { // Keyspace represents the keyspace information for the table. Keyspace *vindexes.Keyspace // TableName represents the name of the table. TableName sqlparser.TableName // Values are the supplied values for the column, which // will be stored as a list within the expression. New // values will be generated based on how many were not // supplied (NULL). Values evalengine.Expr // Insert using Select, offset for auto increment column Offset int // contains filtered or unexported fields }
Generate represents an auto-increment generator for the insert operation.
type GroupBy ¶
type GroupBy struct { Inner sqlparser.Expr // The index at which the user expects to see this column. Set to nil, if the user does not ask for it InnerIndex *int // points to the column on the same aggregator ColOffset int WSOffset int }
GroupBy contains the expression to used in group by and also if grouping is needed at VTGate level then what the weight_string function expression to be sent down for evaluation.
func NewGroupBy ¶
NewGroupBy creates a new group by from the given fields.
type HashJoin ¶
type HashJoin struct {
LHS, RHS Operator
// LeftJoin will be true in the case of an outer join
LeftJoin bool
// Before offset planning
JoinComparisons []Comparison
// Columns stores the column indexes of the columns coming from the left and right side
// negative value comes from LHS and positive from RHS
ColumnOffsets []int
// These are the values that will be hashed together
LHSKeys, RHSKeys []int
// contains filtered or unexported fields
}
func NewHashJoin ¶
func (*HashJoin) AddColumn ¶
func (hj *HashJoin) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, expr *sqlparser.AliasedExpr) int
func (*HashJoin) AddJoinPredicate ¶
func (hj *HashJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
func (*HashJoin) AddPredicate ¶
func (hj *HashJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*HashJoin) AddWSColumn ¶
func (hj *HashJoin) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*HashJoin) FindCol ¶
func (hj *HashJoin) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
func (*HashJoin) GetColumns ¶
func (hj *HashJoin) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*HashJoin) GetOrdering ¶
func (hj *HashJoin) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*HashJoin) GetSelectExprs ¶
func (hj *HashJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*HashJoin) JoinPredicate ¶
JoinPredicate produces an AST representation of the join condition this join has
func (*HashJoin) ShortDescription ¶
type Horizon ¶
type Horizon struct { Source Operator // If this is a derived table, the two following fields will contain the tableID and name of it TableId *semantics.TableSet Alias string ColumnAliases sqlparser.Columns // derived tables can have their column aliases specified outside the subquery // QP contains the QueryProjection for this op QP *QueryProjection Query sqlparser.SelectStatement // Columns needed to feed other plans Columns []*sqlparser.ColName ColumnsOffset []int }
Horizon is an operator that allows us to postpone planning things like SELECT/GROUP BY/ORDER BY/LIMIT until later. It contains information about the planning we have to do after deciding how we will send the query to the tablets. If we are able to push down the Horizon under a route, we don't have to plan these things separately and can just copy over the AST constructs to the query being sent to a tablet. If we are not able to push it down, this operator needs to be split up into smaller Project/Aggregate/Sort/Limit operations, some which can be pushed down, and some that have to be evaluated at the vtgate level.
func (*Horizon) AddColumn ¶
func (h *Horizon) AddColumn(ctx *plancontext.PlanningContext, reuse bool, _ bool, expr *sqlparser.AliasedExpr) int
func (*Horizon) AddPredicate ¶
func (h *Horizon) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Horizon) AddWSColumn ¶
func (h *Horizon) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Horizon) FindCol ¶
func (h *Horizon) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Horizon) GetColumns ¶
func (h *Horizon) GetColumns(ctx *plancontext.PlanningContext) (exprs []*sqlparser.AliasedExpr)
func (*Horizon) GetOrdering ¶
func (h *Horizon) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Horizon) GetSelectExprs ¶
func (h *Horizon) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Horizon) IsMergeable ¶
func (h *Horizon) IsMergeable(ctx *plancontext.PlanningContext) bool
IsMergeable is not a great name for this function. Suggestions for a better one are welcome! This function will return false if the derived table inside it has to run on the vtgate side, and so can't be merged with subqueries This logic can also be used to check if this is a derived table that can be had on the left hand side of a vtgate join. Since vtgate joins are always nested loop joins, we can't execute them on the RHS if they do some things, like LIMIT or GROUP BY on wrong columns
func (*Horizon) ShortDescription ¶
type InfoSchemaRouting ¶
type InfoSchemaRouting struct { SysTableTableSchema []sqlparser.Expr SysTableTableName map[string]sqlparser.Expr Table *QueryTable }
InfoSchemaRouting used for information_schema queries. They are special because we usually don't know at plan-time what keyspace the query go to, because we don't see normalized literal values
func (*InfoSchemaRouting) Clone ¶
func (isr *InfoSchemaRouting) Clone() Routing
func (*InfoSchemaRouting) Cost ¶
func (isr *InfoSchemaRouting) Cost() int
func (*InfoSchemaRouting) Keyspace ¶
func (isr *InfoSchemaRouting) Keyspace() *vindexes.Keyspace
func (*InfoSchemaRouting) OpCode ¶
func (isr *InfoSchemaRouting) OpCode() engine.Opcode
func (*InfoSchemaRouting) UpdateRoutingParams ¶
func (isr *InfoSchemaRouting) UpdateRoutingParams(ctx *plancontext.PlanningContext, rp *engine.RoutingParameters)
type Insert ¶
type Insert struct { // VTable represents the target table for the insert operation. VTable *vindexes.Table // AST represents the insert statement from the SQL syntax. AST *sqlparser.Insert // AutoIncrement represents the auto-increment generator for the insert operation. AutoIncrement *Generate // Ignore specifies whether to ignore duplicate key errors during insertion. Ignore bool // ColVindexes are the vindexes that will use the VindexValues or VindexValueOffset ColVindexes []*vindexes.ColumnVindex // VindexValues specifies values for all the vindex columns. VindexValues [][][]evalengine.Expr // VindexValueOffset stores the offset for each column in the ColumnVindex // that will appear in the result set of the select query. VindexValueOffset [][]int // contains filtered or unexported fields }
Insert represents an insert operation on a table.
func (Insert) AddColumn ¶
func (Insert) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (Insert) AddPredicate ¶
func (Insert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (Insert) AddWSColumn ¶
func (Insert) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (Insert) FindCol ¶
func (Insert) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Insert) GetColumns ¶
func (Insert) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Insert) GetOrdering ¶
func (i *Insert) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (Insert) GetSelectExprs ¶
func (Insert) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (Insert) SetInputs ¶
func (Insert) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*Insert) ShortDescription ¶
func (*Insert) TablesUsed ¶
type InsertSelection ¶
type InsertSelection struct { Select Operator Insert Operator // ForceNonStreaming when true, select first then insert, this is to avoid locking rows by select for insert. ForceNonStreaming bool // contains filtered or unexported fields }
InsertSelection operator represents an INSERT into SELECT FROM query. It holds the operators for running the selection and insertion.
func (InsertSelection) AddColumn ¶
func (InsertSelection) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (InsertSelection) AddPredicate ¶
func (InsertSelection) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (InsertSelection) AddWSColumn ¶
func (InsertSelection) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*InsertSelection) Clone ¶
func (is *InsertSelection) Clone(inputs []Operator) Operator
func (InsertSelection) FindCol ¶
func (InsertSelection) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (InsertSelection) GetColumns ¶
func (InsertSelection) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*InsertSelection) GetOrdering ¶
func (is *InsertSelection) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (InsertSelection) GetSelectExprs ¶
func (InsertSelection) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*InsertSelection) Inputs ¶
func (is *InsertSelection) Inputs() []Operator
func (*InsertSelection) SetInputs ¶
func (is *InsertSelection) SetInputs(inputs []Operator)
func (*InsertSelection) ShortDescription ¶
func (is *InsertSelection) ShortDescription() string
type Join ¶
type Join struct {
LHS, RHS Operator
Predicate sqlparser.Expr
// JoinType is permitted to store only 3 of the possible values
// NormalJoinType, StraightJoinType and LeftJoinType.
JoinType sqlparser.JoinType
// contains filtered or unexported fields
}
Join represents a join. If we have a predicate, this is an inner join. If no predicate exists, it is a cross join
func (Join) AddColumn ¶
func (Join) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (*Join) AddJoinPredicate ¶
func (j *Join) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr)
func (*Join) AddPredicate ¶
func (j *Join) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (Join) AddWSColumn ¶
func (Join) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Join) Compact ¶
func (j *Join) Compact(ctx *plancontext.PlanningContext) (Operator, *ApplyResult)
func (Join) FindCol ¶
func (Join) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Join) GetColumns ¶
func (Join) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Join) GetOrdering ¶
func (j *Join) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (Join) GetSelectExprs ¶
func (Join) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Join) ShortDescription ¶
type JoinOp ¶
type JoinOp interface { Operator GetLHS() Operator GetRHS() Operator SetLHS(Operator) SetRHS(Operator) MakeInner() IsInner() bool AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) }
type Limit ¶
type Limit struct { Source Operator AST *sqlparser.Limit // Top is true if the limit is a top level limit. To optimise, we push LIMIT to the RHS of joins, // but we need to still LIMIT the total result set to the top level limit. Top bool // Once we have pushed the top level Limit down, we mark it as pushed so that we don't push it down again. Pushed bool }
func (*Limit) AddColumn ¶
func (l *Limit) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Limit) AddPredicate ¶
func (l *Limit) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Limit) AddWSColumn ¶
func (l *Limit) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Limit) FindCol ¶
func (l *Limit) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Limit) GetColumns ¶
func (l *Limit) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Limit) GetOrdering ¶
func (l *Limit) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Limit) GetSelectExprs ¶
func (l *Limit) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Limit) ShortDescription ¶
type LockAndComment ¶
type LockAndComment struct { Source Operator Comments *sqlparser.ParsedComments Lock sqlparser.Lock }
LockAndComment contains any comments or locking directives we want on all queries down from this operator
func (*LockAndComment) AddColumn ¶
func (l *LockAndComment) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, expr *sqlparser.AliasedExpr) int
func (*LockAndComment) AddPredicate ¶
func (l *LockAndComment) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*LockAndComment) AddWSColumn ¶
func (l *LockAndComment) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*LockAndComment) Clone ¶
func (l *LockAndComment) Clone(inputs []Operator) Operator
func (*LockAndComment) FindCol ¶
func (l *LockAndComment) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*LockAndComment) GetColumns ¶
func (l *LockAndComment) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*LockAndComment) GetOrdering ¶
func (l *LockAndComment) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*LockAndComment) GetSelectExprs ¶
func (l *LockAndComment) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*LockAndComment) Inputs ¶
func (l *LockAndComment) Inputs() []Operator
func (*LockAndComment) SetInputs ¶
func (l *LockAndComment) SetInputs(operators []Operator)
func (*LockAndComment) ShortDescription ¶
func (l *LockAndComment) ShortDescription() string
type NoneRouting ¶
type NoneRouting struct {
// contains filtered or unexported fields
}
NoneRouting is used when we know that this Route will return no results. Can be merged with any other route going to the same keyspace
func (*NoneRouting) Clone ¶
func (n *NoneRouting) Clone() Routing
func (*NoneRouting) Cost ¶
func (n *NoneRouting) Cost() int
func (*NoneRouting) Keyspace ¶
func (n *NoneRouting) Keyspace() *vindexes.Keyspace
func (*NoneRouting) OpCode ¶
func (n *NoneRouting) OpCode() engine.Opcode
func (*NoneRouting) UpdateRoutingParams ¶
func (n *NoneRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
type Offset ¶
type Offset int
Offset is used when we are only passing through data from an incoming column
type Operator ¶
type Operator interface { // Clone will return a copy of this operator, protected so changed to the original will not impact the clone Clone(inputs []Operator) Operator // Inputs returns the inputs for this operator Inputs() []Operator // SetInputs changes the inputs for this op SetInputs([]Operator) // AddPredicate is used to push predicates. It pushed it as far down as is possible in the tree. // If we encounter a join and the predicate depends on both sides of the join, the predicate will be split into two parts, // where data is fetched from the LHS of the join to be used in the evaluation on the RHS // TODO: we should remove this and replace it with rewriters AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, expr *sqlparser.AliasedExpr) int // AddWSColumn is used to add a weight_string column to the operator AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs ShortDescription() string GetOrdering(ctx *plancontext.PlanningContext) []OrderBy }
Operator forms the tree of operators, representing the declarative query provided. The operator tree is no actually runnable, it's an intermediate representation used while query planning The mental model are operators that pull data from each other, the root being the full query output, and the leaves are most often `Route`s, representing communication with one or more shards. We want to push down as much work as possible under these Routes
func AddPredicate ¶
func BottomUp ¶
func BottomUp( root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, shouldVisit ShouldVisit, ) Operator
BottomUp rewrites an operator tree from the bottom up. BottomUp applies a transformation function to the given operator tree from the bottom up. Each callback [f] returns a ApplyResult that is aggregated into a final output indicating whether the operator tree was changed.
func FixedPointBottomUp ¶
func FixedPointBottomUp( root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, shouldVisit ShouldVisit, ) (op Operator)
FixedPointBottomUp rewrites an operator tree much like BottomUp does, but does the rewriting repeatedly, until a tree walk is done with no changes to the tree.
func PlanQuery ¶
func PlanQuery(ctx *plancontext.PlanningContext, stmt sqlparser.Statement) (result Operator, err error)
PlanQuery creates a query plan for a given SQL statement
func ToSQL ¶
func ToSQL(ctx *plancontext.PlanningContext, op Operator) (_ sqlparser.Statement, _ Operator, err error)
func TopDown ¶
func TopDown( root Operator, resolveID func(Operator) semantics.TableSet, visit VisitF, shouldVisit ShouldVisit, ) Operator
TopDown rewrites an operator tree from the bottom up. BottomUp applies a transformation function to the given operator tree from the bottom up. Each callback [f] returns a ApplyResult that is aggregated into a final output indicating whether the operator tree was changed.
Parameters: - root: The root operator of the tree to be traversed. - resolveID: A function to resolve the TableSet of an operator. - visit: The VisitF function to be called for each visited operator. - shouldVisit: The ShouldVisit function to control which nodes and ancestors to visit and which to skip.
Returns: - Operator: The root of the (potentially) transformed operator tree. - error: An error if any occurred during the traversal.
type OrderBy ¶
type OrderBy struct { Inner *sqlparser.Order // See GroupBy#SimplifiedExpr for more details about this SimplifiedExpr sqlparser.Expr }
OrderBy contains the expression to used in order by and also if ordering is needed at VTGate level then what the weight_string function expression to be sent down for evaluation.
type Ordering ¶
type Ordering struct { Source Operator Offset []int WOffset []int Order []OrderBy ResultColumns int }
func (*Ordering) AddColumn ¶
func (o *Ordering) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Ordering) AddPredicate ¶
func (o *Ordering) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Ordering) AddWSColumn ¶
func (o *Ordering) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Ordering) FindCol ¶
func (o *Ordering) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Ordering) GetColumns ¶
func (o *Ordering) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Ordering) GetOrdering ¶
func (o *Ordering) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (*Ordering) GetSelectExprs ¶
func (o *Ordering) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Ordering) ShortDescription ¶
type ProjCols ¶
type ProjCols interface { GetColumns() []*sqlparser.AliasedExpr GetSelectExprs() sqlparser.SelectExprs }
ProjCols is used to enable projections that are only valid if we can push them into a route, and we never need to ask it about offsets
type ProjExpr ¶
type ProjExpr struct { Original *sqlparser.AliasedExpr // this is the expression the user asked for. should only be used to decide on the column alias EvalExpr sqlparser.Expr // EvalExpr is the expression that will be evaluated at runtime ColExpr sqlparser.Expr // ColExpr is used during planning to figure out which column this ProjExpr is representing Info ExprInfo // Here we store information about evalengine, offsets or subqueries }
type Projection ¶
type Projection struct { Source Operator // Columns contain the expressions as viewed from the outside of this operator Columns ProjCols // DT will hold all the necessary information if this is a derived table projection DT *DerivedTable FromAggr bool }
Projection is used when we need to evaluate expressions on the vtgate It uses the evalengine to accomplish its goal
func (*Projection) AddColumn ¶
func (p *Projection) AddColumn(ctx *plancontext.PlanningContext, reuse bool, addToGroupBy bool, ae *sqlparser.AliasedExpr) int
func (*Projection) AddPredicate ¶
func (p *Projection) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Projection) AddWSColumn ¶
func (p *Projection) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Projection) AllOffsets ¶
func (p *Projection) AllOffsets() (cols []int, colNames []string)
AllOffsets returns a slice of integer offsets for all columns in the Projection if all columns are of type Offset. If any column is not of type Offset, it returns nil.
func (*Projection) Clone ¶
func (p *Projection) Clone(inputs []Operator) Operator
func (*Projection) Compact ¶
func (p *Projection) Compact(ctx *plancontext.PlanningContext) (Operator, *ApplyResult)
func (*Projection) FindCol ¶
func (p *Projection) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Projection) GetAliasedProjections ¶
func (p *Projection) GetAliasedProjections() (AliasedProjections, error)
func (*Projection) GetColumns ¶
func (p *Projection) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Projection) GetOrdering ¶
func (p *Projection) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Projection) GetSelectExprs ¶
func (p *Projection) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Projection) Inputs ¶
func (p *Projection) Inputs() []Operator
func (*Projection) SetInputs ¶
func (p *Projection) SetInputs(operators []Operator)
func (*Projection) ShortDescription ¶
func (p *Projection) ShortDescription() string
type QueryGraph ¶
type QueryGraph struct { // the Tables, including predicates that only depend on this particular table Tables []*QueryTable // NoDeps contains the predicates that can be evaluated anywhere. NoDeps sqlparser.Expr // contains filtered or unexported fields }
QueryGraph represents the FROM and WHERE parts of a query.
It is an intermediate representation of the query that makes it easier for the planner to find all possible join combinations. Instead of storing the query information in a form that is close to the syntax (AST), we extract the interesting parts into a graph form with the nodes being tables in the FROM clause and the edges between them being predicates. We keep predicates in a hash map keyed by the dependencies of the predicate. This makes it very fast to look up connections between tables in the query.
func (QueryGraph) AddColumn ¶
func (QueryGraph) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (*QueryGraph) AddPredicate ¶
func (qg *QueryGraph) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (QueryGraph) AddWSColumn ¶
func (QueryGraph) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*QueryGraph) Clone ¶
func (qg *QueryGraph) Clone([]Operator) Operator
Clone implements the Operator interface
func (QueryGraph) FindCol ¶
func (QueryGraph) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (QueryGraph) GetColumns ¶
func (QueryGraph) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*QueryGraph) GetOrdering ¶
func (qg *QueryGraph) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (*QueryGraph) GetPredicates ¶
func (qg *QueryGraph) GetPredicates(lhs, rhs semantics.TableSet) []sqlparser.Expr
GetPredicates returns the predicates that are applicable for the two given TableSets
func (QueryGraph) GetSelectExprs ¶
func (QueryGraph) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (QueryGraph) Inputs ¶
func (QueryGraph) Inputs() []Operator
Inputs implements the Operator interface
func (QueryGraph) SetInputs ¶
func (QueryGraph) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*QueryGraph) ShortDescription ¶
func (qg *QueryGraph) ShortDescription() string
func (*QueryGraph) UnsolvedPredicates ¶
func (qg *QueryGraph) UnsolvedPredicates(_ *semantics.SemTable) []sqlparser.Expr
UnsolvedPredicates implements the unresolved interface
type QueryProjection ¶
type QueryProjection struct { // If you change the contents here, please update the toString() method SelectExprs []SelectExpr HasAggr bool Distinct bool WithRollup bool OrderExprs []OrderBy // AddedColumn keeps a counter for expressions added to solve HAVING expressions the user is not selecting AddedColumn int // contains filtered or unexported fields }
QueryProjection contains the information about the projections, group by and order by expressions used to do horizon planning.
func CreateQPFromSelectStatement ¶
func CreateQPFromSelectStatement(ctx *plancontext.PlanningContext, stmt sqlparser.SelectStatement) *QueryProjection
func (*QueryProjection) AddGroupBy ¶
func (qp *QueryProjection) AddGroupBy(by GroupBy)
AddGroupBy does just that
func (*QueryProjection) AggregationExpressions ¶
func (qp *QueryProjection) AggregationExpressions(ctx *plancontext.PlanningContext, allowComplexExpression bool) (out []Aggr, complex bool)
func (*QueryProjection) AlignGroupByAndOrderBy ¶
func (qp *QueryProjection) AlignGroupByAndOrderBy(ctx *plancontext.PlanningContext) bool
AlignGroupByAndOrderBy aligns the group by and order by columns, so they are in the same order The GROUP BY clause is a set - the order between the elements does not make any difference, so we can simply re-arrange the column order We are also free to add more ORDER BY columns than the user asked for which we leverage, so the input is already ordered according to the GROUP BY columns used
func (*QueryProjection) FindSelectExprIndexForExpr ¶
func (qp *QueryProjection) FindSelectExprIndexForExpr(ctx *plancontext.PlanningContext, expr sqlparser.Expr) *int
FindSelectExprIndexForExpr returns the index of the given expression in the select expressions, if it is part of it returns -1 otherwise.
func (*QueryProjection) GetColumnCount ¶
func (qp *QueryProjection) GetColumnCount() int
func (*QueryProjection) GetGrouping ¶
func (qp *QueryProjection) GetGrouping() []GroupBy
GetGrouping returns a copy of the grouping parameters of the QP
func (*QueryProjection) NeedsAggregation ¶
func (qp *QueryProjection) NeedsAggregation() bool
NeedsAggregation returns true if we either have aggregate functions or grouping defined
func (*QueryProjection) NeedsDistinct ¶
func (qp *QueryProjection) NeedsDistinct() bool
NeedsDistinct returns true if the query needs explicit distinct
func (*QueryProjection) OldAlignGroupByAndOrderBy ¶
func (qp *QueryProjection) OldAlignGroupByAndOrderBy(ctx *plancontext.PlanningContext)
OldAlignGroupByAndOrderBy TODO Remove once all of horizon planning is done on the operators
type QueryTable ¶
type QueryTable struct { ID semantics.TableSet Alias *sqlparser.AliasedTableExpr Table sqlparser.TableName Predicates []sqlparser.Expr IsInfSchema bool }
QueryTable is a single FROM table, including all predicates particular to this table This is to be used as an immutable data structure which is created in the logical Operator Tree
func (*QueryTable) Clone ¶
func (qt *QueryTable) Clone() *QueryTable
Clone implements the Operator interface
type Route ¶
type Route struct { Source Operator // Routes that have been merged into this one. MergedWith []*Route Routing Routing Ordering []RouteOrdering Comments *sqlparser.ParsedComments Lock sqlparser.Lock ResultColumns int }
func (*Route) AddColumn ¶
func (r *Route) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Route) AddPredicate ¶
func (r *Route) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Route) AddWSColumn ¶
func (r *Route) AddWSColumn(ctx *plancontext.PlanningContext, offset int, _ bool) int
func (*Route) FindCol ¶
func (r *Route) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, _ bool) int
func (*Route) GetColumns ¶
func (r *Route) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Route) GetOrdering ¶
func (r *Route) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*Route) GetSelectExprs ¶
func (r *Route) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Route) IsSingleShard ¶
func (*Route) IsSingleShardOrByDestination ¶
func (*Route) ShortDescription ¶
func (*Route) TablesUsed ¶
TablesUsed returns tables used by MergedWith routes, which are not included in Inputs() and thus not a part of the operator tree
type RouteOrdering ¶
type RouteOrdering struct { AST sqlparser.Expr // Offset and WOffset will contain the offset to the column (and the weightstring column). -1 if it's missing Offset, WOffset int Direction sqlparser.OrderDirection }
type Routing ¶
type Routing interface { // UpdateRoutingParams allows a Routing to control the routing params that will be used by the engine Route // OpCode is already set, and the default keyspace is set for read queries UpdateRoutingParams(ctx *plancontext.PlanningContext, rp *engine.RoutingParameters) // Clone returns a copy of the routing. Since we are trying different variation of merging, // one Routing can be used in different constellations. // We don't want these different alternatives to influence each other, and cloning allows this Clone() Routing // Cost returns the cost of this Route. Cost() int OpCode() engine.Opcode Keyspace() *vindexes.Keyspace // note that all routings do not have a keyspace, so this method can return nil // contains filtered or unexported methods }
Routing is used for the routing and merging logic of `Route`s. Every Route has a Routing object, and this object is updated when predicates are found, and when merging `Route`s together
func UpdateRoutingLogic ¶
func UpdateRoutingLogic(ctx *plancontext.PlanningContext, expr sqlparser.Expr, r Routing) Routing
UpdateRoutingLogic first checks if we are dealing with a predicate that
type SelectExpr ¶
type SelectExpr struct { Col sqlparser.SelectExpr Aggr bool }
SelectExpr provides whether the column is aggregation expression or not.
func (SelectExpr) GetAliasedExpr ¶
func (s SelectExpr) GetAliasedExpr() (*sqlparser.AliasedExpr, error)
GetAliasedExpr returns the SelectExpr as a *sqlparser.AliasedExpr if its type allows it, otherwise an error is returned.
type SequenceRouting ¶
type SequenceRouting struct {
// contains filtered or unexported fields
}
func (*SequenceRouting) Clone ¶
func (sr *SequenceRouting) Clone() Routing
func (*SequenceRouting) Cost ¶
func (sr *SequenceRouting) Cost() int
func (*SequenceRouting) Keyspace ¶
func (sr *SequenceRouting) Keyspace() *vindexes.Keyspace
func (*SequenceRouting) OpCode ¶
func (sr *SequenceRouting) OpCode() engine.Opcode
func (*SequenceRouting) UpdateRoutingParams ¶
func (sr *SequenceRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
type Sequential ¶
type Sequential struct { Sources []Operator // contains filtered or unexported fields }
func (Sequential) AddColumn ¶
func (Sequential) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (Sequential) AddPredicate ¶
func (Sequential) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (Sequential) AddWSColumn ¶
func (Sequential) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Sequential) Clone ¶
func (s *Sequential) Clone(inputs []Operator) Operator
Clone implements the Operator interface
func (Sequential) FindCol ¶
func (Sequential) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Sequential) GetColumns ¶
func (Sequential) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Sequential) GetOrdering ¶
func (s *Sequential) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (Sequential) GetSelectExprs ¶
func (Sequential) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Sequential) Inputs ¶
func (s *Sequential) Inputs() []Operator
Inputs implements the Operator interface
func (*Sequential) SetInputs ¶
func (s *Sequential) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*Sequential) ShortDescription ¶
func (s *Sequential) ShortDescription() string
type ShardedRouting ¶
type ShardedRouting struct { // here we store the possible vindexes we can use so that when we add predicates to the plan, // we can quickly check if the new predicates enables any new vindex Options VindexPreds []*VindexPlusPredicates // the best option available is stored here Selected *VindexOption RouteOpCode engine.Opcode // SeenPredicates contains all the predicates that have had a chance to influence routing. // If we need to replan routing, we'll use this list SeenPredicates []sqlparser.Expr // contains filtered or unexported fields }
ShardedRouting is what we use for all tables that exist in a sharded keyspace It knows about available vindexes and can use them for routing when applicable
func (*ShardedRouting) Clone ¶
func (tr *ShardedRouting) Clone() Routing
func (*ShardedRouting) Cost ¶
func (tr *ShardedRouting) Cost() int
func (*ShardedRouting) Keyspace ¶
func (tr *ShardedRouting) Keyspace() *vindexes.Keyspace
func (*ShardedRouting) OpCode ¶
func (tr *ShardedRouting) OpCode() engine.Opcode
func (*ShardedRouting) PickBestAvailableVindex ¶
func (tr *ShardedRouting) PickBestAvailableVindex()
PickBestAvailableVindex goes over the available vindexes for this route and picks the best one available.
func (*ShardedRouting) SelectedVindex ¶
func (tr *ShardedRouting) SelectedVindex() vindexes.Vindex
func (*ShardedRouting) UpdateRoutingParams ¶
func (tr *ShardedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
func (*ShardedRouting) VindexExpressions ¶
func (tr *ShardedRouting) VindexExpressions() []sqlparser.Expr
type ShouldVisit ¶
ShouldVisit is used when we want to control which nodes and ancestors to visit and which to skip
type StarProjections ¶
type StarProjections sqlparser.SelectExprs
Used when there are stars in the expressions that we were unable to expand
func (StarProjections) GetColumns ¶
func (sp StarProjections) GetColumns() []*sqlparser.AliasedExpr
func (StarProjections) GetSelectExprs ¶
func (sp StarProjections) GetSelectExprs() sqlparser.SelectExprs
type SubQuery ¶
type SubQuery struct { // Fields filled in at the time of construction: Outer Operator // Outer query operator. Subquery Operator // Subquery operator. FilterType opcode.PulloutOpcode // Type of subquery filter. Original sqlparser.Expr // This is the expression we should use if we can merge the inner to the outer Predicates sqlparser.Exprs // Predicates joining outer and inner queries. Empty for uncorrelated subqueries. OuterPredicate sqlparser.Expr // This is the predicate that is using the subquery expression. It will not be empty for projections ArgName string // This is the name of the ColName or Argument used to replace the subquery TopLevel bool // will be false if the subquery is deeply nested JoinColumns []applyJoinColumn // Broken up join predicates. SubqueryValueName string // Value name returned by the subquery (uncorrelated queries). HasValuesName string // Argument name passed to the subquery (uncorrelated queries). // Fields related to correlated subqueries: Vars map[string]int // Arguments copied from outer to inner, set during offset planning. // IsArgument is set to true if the subquery puts the IsArgument bool // contains filtered or unexported fields }
SubQuery represents a subquery used for filtering rows in an outer query through a join.
func (*SubQuery) AddColumn ¶
func (sq *SubQuery) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, ae *sqlparser.AliasedExpr) int
func (*SubQuery) AddPredicate ¶
func (sq *SubQuery) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*SubQuery) AddWSColumn ¶
func (sq *SubQuery) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*SubQuery) FindCol ¶
func (sq *SubQuery) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*SubQuery) GetColumns ¶
func (sq *SubQuery) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*SubQuery) GetJoinColumns ¶
func (sq *SubQuery) GetJoinColumns(ctx *plancontext.PlanningContext, outer Operator) ([]applyJoinColumn, error)
func (*SubQuery) GetMergePredicates ¶
GetMergePredicates returns the predicates that we can use to try to merge this subquery with the outer query.
func (*SubQuery) GetOrdering ¶
func (sq *SubQuery) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*SubQuery) GetSelectExprs ¶
func (sq *SubQuery) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*SubQuery) OuterExpressionsNeeded ¶
func (sq *SubQuery) OuterExpressionsNeeded(ctx *plancontext.PlanningContext, outer Operator) (result []*sqlparser.ColName)
func (*SubQuery) ShortDescription ¶
type SubQueryBuilder ¶
type SubQueryBuilder struct { Inner []*SubQuery // contains filtered or unexported fields }
type SubQueryContainer ¶
SubQueryContainer stores the information about a query and it's subqueries. The inner subqueries can be executed in any order, so we store them like this so we can see more opportunities for merging
func (*SubQueryContainer) AddColumn ¶
func (sqc *SubQueryContainer) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, exprs *sqlparser.AliasedExpr) int
func (*SubQueryContainer) AddPredicate ¶
func (sqc *SubQueryContainer) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*SubQueryContainer) AddWSColumn ¶
func (sqc *SubQueryContainer) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*SubQueryContainer) Clone ¶
func (sqc *SubQueryContainer) Clone(inputs []Operator) Operator
Clone implements the Operator interface
func (*SubQueryContainer) FindCol ¶
func (sqc *SubQueryContainer) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*SubQueryContainer) GetColumns ¶
func (sqc *SubQueryContainer) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*SubQueryContainer) GetOrdering ¶
func (sqc *SubQueryContainer) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (*SubQueryContainer) GetSelectExprs ¶
func (sqc *SubQueryContainer) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*SubQueryContainer) Inputs ¶
func (sqc *SubQueryContainer) Inputs() []Operator
Inputs implements the Operator interface
func (*SubQueryContainer) SetInputs ¶
func (sqc *SubQueryContainer) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*SubQueryContainer) ShortDescription ¶
func (sqc *SubQueryContainer) ShortDescription() string
type SubQueryExpression ¶
type SubQueryExpression []*SubQuery
type Table ¶
type Table struct { QTable *QueryTable VTable *vindexes.Table Columns []*sqlparser.ColName // contains filtered or unexported fields }
func (*Table) AddColumn ¶
func (to *Table) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
func (*Table) AddPredicate ¶
func (to *Table) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) Operator
AddPredicate implements the PhysicalOperator interface
func (*Table) AddWSColumn ¶
func (*Table) AddWSColumn(*plancontext.PlanningContext, int, bool) int
func (*Table) FindCol ¶
func (to *Table) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Table) GetColNames ¶
func (*Table) GetColumns ¶
func (to *Table) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Table) GetOrdering ¶
func (to *Table) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (*Table) GetSelectExprs ¶
func (to *Table) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (Table) SetInputs ¶
func (Table) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*Table) ShortDescription ¶
func (*Table) TablesUsed ¶
type TableUser ¶
type TableUser interface {
TablesUsed() []string
}
TableUser is used to signal that this operator directly interacts with one or more tables
type TargetTable ¶
type TargetedRouting ¶
type TargetedRouting struct { // targetDestination specifies an explicit target destination tablet type TargetDestination key.Destination // contains filtered or unexported fields }
TargetedRouting is used when the user has used syntax to target the Route against a specific set of shards and/or tablet type. Can't be merged with anything else.
func (*TargetedRouting) Clone ¶
func (tr *TargetedRouting) Clone() Routing
func (*TargetedRouting) Cost ¶
func (tr *TargetedRouting) Cost() int
func (*TargetedRouting) Keyspace ¶
func (tr *TargetedRouting) Keyspace() *vindexes.Keyspace
func (*TargetedRouting) OpCode ¶
func (tr *TargetedRouting) OpCode() engine.Opcode
func (*TargetedRouting) UpdateRoutingParams ¶
func (tr *TargetedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters)
type Union ¶
type Union struct { Sources []Operator // These are the select expressions coming from each source Selects []sqlparser.SelectExprs // contains filtered or unexported fields }
func (*Union) AddColumn ¶
func (u *Union) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, expr *sqlparser.AliasedExpr) int
func (*Union) AddPredicate ¶
func (u *Union) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
AddPredicate adds a predicate a UNION by pushing the predicate to all sources of the UNION.
this is done by offset and expression rewriting. Say we have a query like so:
select * (
select foo as col, bar from tbl1 union select id, baz from tbl2
) as X where X.col = 42
We want to push down the `X.col = 42` as far down the operator tree as possible. We want to end up with an operator tree that looks something like this:
select * (
select foo as col, bar from tbl1 where foo = 42 union select id, baz from tbl2 where id = 42
) as X
Notice how `X.col = 42` has been translated to `foo = 42` and `id = 42` on respective WHERE clause. The first SELECT of the union dictates the column names, and the second is whatever expression can be found on the same offset. The names of the RHS are discarded.
func (*Union) AddWSColumn ¶
func (u *Union) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (*Union) FindCol ¶
func (u *Union) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Union) GetColumns ¶
func (u *Union) GetColumns(ctx *plancontext.PlanningContext) (result []*sqlparser.AliasedExpr)
func (*Union) GetOrdering ¶
func (u *Union) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (*Union) GetSelectExprs ¶
func (u *Union) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (*Union) NoLHSTableSet ¶
func (u *Union) NoLHSTableSet()
func (*Union) ShortDescription ¶
type Update ¶
type Update struct { *DMLCommon Assignments []SetExpr ChangedVindexValues map[string]*engine.VindexValues // these subqueries cannot be merged as they are part of the changed vindex values // these values are needed to be sent over to lookup vindex for update. // On merging this information will be lost, so subquery merge is blocked. SubQueriesArgOnChangedVindex []string VerifyAll bool // contains filtered or unexported fields }
func (Update) AddColumn ¶
func (Update) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (Update) AddPredicate ¶
func (Update) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (Update) AddWSColumn ¶
func (Update) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (Update) FindCol ¶
func (Update) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Update) GetColumns ¶
func (Update) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Update) GetOrdering ¶
func (u *Update) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (Update) GetSelectExprs ¶
func (Update) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Update) ShortDescription ¶
func (*Update) TablesUsed ¶
type Upsert ¶
type Upsert struct { Sources []UpsertSource // contains filtered or unexported fields }
Upsert represents an insert on duplicate key operation on a table.
func (Upsert) AddColumn ¶
func (Upsert) AddColumn(*plancontext.PlanningContext, bool, bool, *sqlparser.AliasedExpr) int
AddColumn implements the Operator interface
func (Upsert) AddPredicate ¶
func (Upsert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) Operator
AddPredicate implements the Operator interface
func (Upsert) AddWSColumn ¶
func (Upsert) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int
func (Upsert) FindCol ¶
func (Upsert) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int
func (Upsert) GetColumns ¶
func (Upsert) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Upsert) GetOrdering ¶
func (u *Upsert) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy
func (Upsert) GetSelectExprs ¶
func (Upsert) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs
func (*Upsert) ShortDescription ¶
type UpsertSource ¶
type VerifyOp ¶
VerifyOp keeps the information about the foreign key verification operation. It is a Parent verification or a Child verification.
type Vindex ¶
type Vindex struct { OpCode engine.VindexOpcode Table VindexTable Vindex vindexes.Vindex Solved semantics.TableSet Columns []*sqlparser.ColName Value sqlparser.Expr // contains filtered or unexported fields }
func (*Vindex) AddColumn ¶
func (v *Vindex) AddColumn(ctx *plancontext.PlanningContext, reuse bool, gb bool, ae *sqlparser.AliasedExpr) int
func (*Vindex) AddPredicate ¶
func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator
func (*Vindex) AddWSColumn ¶
func (*Vindex) AddWSColumn(*plancontext.PlanningContext, int, bool) int
func (*Vindex) CheckValid ¶
func (v *Vindex) CheckValid()
func (*Vindex) FindCol ¶
func (v *Vindex) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int
func (*Vindex) GetColNames ¶
func (*Vindex) GetColumns ¶
func (v *Vindex) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedExpr
func (*Vindex) GetOrdering ¶
func (v *Vindex) GetOrdering(*plancontext.PlanningContext) []OrderBy
func (*Vindex) GetSelectExprs ¶
func (v *Vindex) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs
func (Vindex) SetInputs ¶
func (Vindex) SetInputs(ops []Operator)
SetInputs implements the Operator interface
func (*Vindex) ShortDescription ¶
func (*Vindex) TablesUsed ¶
TablesUsed implements the Operator interface. It is not keyspace-qualified.
type VindexOption ¶
type VindexOption struct { Ready bool Values []evalengine.Expr // Columns that we have seen so far. Used only for multi-column vindexes so that we can track how many Columns part of the vindex we have seen ColsSeen map[string]any ValueExprs []sqlparser.Expr Predicates []sqlparser.Expr OpCode engine.Opcode FoundVindex vindexes.Vindex Cost Cost }
VindexOption stores the information needed to know if we have all the information needed to use a vindex
type VindexPlusPredicates ¶
type VindexPlusPredicates struct { TableID semantics.TableSet ColVindex *vindexes.ColumnVindex // during planning, we store the alternatives found for this route in this slice Options []*VindexOption }
VindexPlusPredicates is a struct used to store all the predicates that the vindex can be used to query
type VindexTable ¶
type VindexTable struct { TableID semantics.TableSet Alias *sqlparser.AliasedTableExpr Table sqlparser.TableName Predicates []sqlparser.Expr VTable *vindexes.Table }
VindexTable contains information about the vindex table we want to query
Source Files
¶
- SQL_builder.go
- aggregation_pushing.go
- aggregation_pushing_helper.go
- aggregator.go
- apply_join.go
- ast_to_op.go
- comments.go
- delete.go
- distinct.go
- dml_planning.go
- dml_with_input.go
- expressions.go
- filter.go
- fk_cascade.go
- fk_verify.go
- hash_join.go
- helpers.go
- horizon.go
- horizon_expanding.go
- info_schema_planning.go
- insert.go
- insert_selection.go
- join.go
- join_merging.go
- joins.go
- limit.go
- misc_routing.go
- offset_planning.go
- operator.go
- ordering.go
- phases.go
- plan_query.go
- projection.go
- projection_pushing.go
- query_planning.go
- querygraph.go
- queryprojection.go
- rewriters.go
- route.go
- route_planning.go
- sequential.go
- sharded_routing.go
- subquery.go
- subquery_builder.go
- subquery_container.go
- subquery_planning.go
- table.go
- to_json.go
- union.go
- union_merging.go
- update.go
- upsert.go
- vindex.go