Documentation ¶
Overview ¶
Package operators contains the operators used to plan queries.
The operators go through a few phases while planning:
- Logical In this first pass, we build an operator tree from the incoming parsed query. It will contain logical joins - we still haven't decided on the join algorithm to use yet. At the leaves, it will contain QueryGraphs - these are the tables in the FROM clause that we can easily do join ordering on. The logical tree will represent the full query, including projections, Grouping, ordering and so on.
- Physical Once the logical plan has been fully built, we go bottom up and plan which routes that will be used. During this phase, we will also decide which join algorithms should be used on the vtgate level
- Columns & Aggregation Once we know which queries will be sent to the tablets, we go over the tree and decide which columns each operator should output. At this point, we also do offset lookups, so we know at runtime from which columns in the input table we need to read.
Index ¶
- Constants
- func AddPredicate(ctx *plancontext.PlanningContext, join JoinOp, expr sqlparser.Expr, ...) (ops.Operator, error)
- func Clone(op ops.Operator) ops.Operator
- func CompareRefInt(a *int, b *int) bool
- func CostOf(op ops.Operator) (cost int)
- func IsTableSchemaOrName(e sqlparser.Expr) (col *sqlparser.ColName, isTableSchema bool, isTableName bool)
- func Merge(ctx *plancontext.PlanningContext, lhs, rhs ops.Operator, ...) (ops.Operator, error)
- func NotImplementedSchemaInfoResolver(*sqlparser.ColName) (int, error)
- func PlanQuery(ctx *plancontext.PlanningContext, stmt sqlparser.Statement) (ops.Operator, 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 RemovePredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, op ops.Operator) (ops.Operator, error)
- func SingleQualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) []string
- func SingleQualifiedString(ks *vindexes.Keyspace, s string) []string
- func SortAggregations(a []Aggr)
- func SortGrouping(a []GroupBy)
- func TableID(op ops.Operator) (result semantics.TableSet)
- func TablesUsed(op ops.Operator) []string
- func ToSQL(ctx *plancontext.PlanningContext, op ops.Operator) (sqlparser.SelectStatement, error)
- func UnresolvedPredicates(op ops.Operator, st *semantics.SemTable) (result []sqlparser.Expr)
- type Aggr
- type AggrRewriter
- type Aggregator
- func (a *Aggregator) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (a *Aggregator) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (a *Aggregator) Clone(inputs []ops.Operator) ops.Operator
- func (a *Aggregator) Description() ops.OpDescription
- func (a *Aggregator) GetColumns() (columns []*sqlparser.AliasedExpr, err error)
- func (a *Aggregator) GetOrdering() ([]ops.OrderBy, error)
- func (a *Aggregator) Inputs() []ops.Operator
- func (a *Aggregator) SetInputs(operators []ops.Operator)
- func (a *Aggregator) ShortDescription() string
- 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) error
- type ApplyJoin
- func (a *ApplyJoin) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (a *ApplyJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
- func (a *ApplyJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (a *ApplyJoin) Clone(inputs []ops.Operator) ops.Operator
- func (a *ApplyJoin) Description() ops.OpDescription
- func (a *ApplyJoin) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (a *ApplyJoin) GetLHS() ops.Operator
- func (a *ApplyJoin) GetOrdering() ([]ops.OrderBy, error)
- func (a *ApplyJoin) GetRHS() ops.Operator
- func (a *ApplyJoin) Inputs() []ops.Operator
- func (a *ApplyJoin) IsInner() bool
- func (a *ApplyJoin) MakeInner()
- func (a *ApplyJoin) SetInputs(inputs []ops.Operator)
- func (a *ApplyJoin) SetLHS(operator ops.Operator)
- func (a *ApplyJoin) SetRHS(operator ops.Operator)
- func (a *ApplyJoin) ShortDescription() string
- type ColNameColumns
- type CorrelatedSubQueryOp
- func (CorrelatedSubQueryOp) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (CorrelatedSubQueryOp) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (c *CorrelatedSubQueryOp) Clone(inputs []ops.Operator) ops.Operator
- func (c *CorrelatedSubQueryOp) Description() ops.OpDescription
- func (CorrelatedSubQueryOp) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (c *CorrelatedSubQueryOp) GetOrdering() ([]ops.OrderBy, error)
- func (c *CorrelatedSubQueryOp) Inputs() []ops.Operator
- func (c *CorrelatedSubQueryOp) SetInputs(ops []ops.Operator)
- func (c *CorrelatedSubQueryOp) ShortDescription() string
- type Cost
- type Delete
- func (Delete) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (Delete) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (d *Delete) Clone([]ops.Operator) ops.Operator
- func (d *Delete) Description() ops.OpDescription
- func (Delete) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (d *Delete) GetOrdering() ([]ops.OrderBy, error)
- func (Delete) Inputs() []ops.Operator
- func (d *Delete) Introduces() semantics.TableSet
- func (Delete) SetInputs(ops []ops.Operator)
- func (d *Delete) ShortDescription() string
- func (d *Delete) TablesUsed() []string
- type Derived
- func (d *Derived) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (d *Derived) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (d *Derived) Clone(inputs []ops.Operator) ops.Operator
- func (d *Derived) Description() ops.OpDescription
- func (d *Derived) GetColumns() (exprs []*sqlparser.AliasedExpr, err error)
- func (d *Derived) GetOrdering() ([]ops.OrderBy, error)
- func (d *Derived) Inputs() []ops.Operator
- func (d *Derived) IsMergeable(ctx *plancontext.PlanningContext) bool
- func (d *Derived) SetInputs(ops []ops.Operator)
- func (d *Derived) ShortDescription() string
- type Distinct
- func (d *Distinct) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (d *Distinct) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (d *Distinct) Clone(inputs []ops.Operator) ops.Operator
- func (d *Distinct) Description() ops.OpDescription
- func (d *Distinct) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (d *Distinct) GetOrdering() ([]ops.OrderBy, error)
- func (d *Distinct) Inputs() []ops.Operator
- func (d *Distinct) SetInputs(operators []ops.Operator)
- func (d *Distinct) ShortDescription() string
- type DualRouting
- type Eval
- type Filter
- func (f *Filter) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (f *Filter) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (f *Filter) Clone(inputs []ops.Operator) ops.Operator
- func (f *Filter) Compact(*plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
- func (f *Filter) Description() ops.OpDescription
- func (f *Filter) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (f *Filter) GetOrdering() ([]ops.OrderBy, error)
- func (f *Filter) Inputs() []ops.Operator
- func (f *Filter) SetInputs(ops []ops.Operator)
- func (f *Filter) ShortDescription() string
- func (f *Filter) UnsolvedPredicates(st *semantics.SemTable) []sqlparser.Expr
- type Generate
- type GroupBy
- type Horizon
- func (h *Horizon) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (h *Horizon) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (h *Horizon) Clone(inputs []ops.Operator) ops.Operator
- func (h *Horizon) Description() ops.OpDescription
- func (h *Horizon) GetColumns() (exprs []*sqlparser.AliasedExpr, err error)
- func (h *Horizon) GetOrdering() ([]ops.OrderBy, error)
- func (h *Horizon) Inputs() []ops.Operator
- func (h *Horizon) SetInputs(ops []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(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
- type Insert
- func (Insert) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (Insert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (i *Insert) Clone(inputs []ops.Operator) ops.Operator
- func (i *Insert) Description() ops.OpDescription
- func (Insert) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (i *Insert) GetOrdering() ([]ops.OrderBy, error)
- func (i *Insert) Inputs() []ops.Operator
- func (i *Insert) SetInputs(inputs []ops.Operator)
- func (i *Insert) ShortDescription() string
- func (i *Insert) TablesUsed() []string
- type Join
- func (Join) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (j *Join) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
- func (j *Join) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (j *Join) Clone(inputs []ops.Operator) ops.Operator
- func (j *Join) Compact(ctx *plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
- func (j *Join) Description() ops.OpDescription
- func (Join) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (j *Join) GetLHS() ops.Operator
- func (j *Join) GetOrdering() ([]ops.OrderBy, error)
- func (j *Join) GetRHS() ops.Operator
- func (j *Join) Inputs() []ops.Operator
- func (j *Join) IsInner() bool
- func (j *Join) MakeInner()
- func (j *Join) SetInputs(ops []ops.Operator)
- func (j *Join) SetLHS(operator ops.Operator)
- func (j *Join) SetRHS(operator ops.Operator)
- func (j *Join) ShortDescription() string
- type JoinColumn
- type JoinOp
- type Limit
- func (l *Limit) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (l *Limit) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (l *Limit) Clone(inputs []ops.Operator) ops.Operator
- func (l *Limit) Description() ops.OpDescription
- func (l *Limit) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (l *Limit) GetOrdering() ([]ops.OrderBy, error)
- func (l *Limit) Inputs() []ops.Operator
- func (l *Limit) SetInputs(operators []ops.Operator)
- func (l *Limit) ShortDescription() string
- type NoneRouting
- type Offset
- type Ordering
- func (o *Ordering) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (o *Ordering) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (o *Ordering) Clone(inputs []ops.Operator) ops.Operator
- func (o *Ordering) Description() ops.OpDescription
- func (o *Ordering) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (o *Ordering) GetOrdering() ([]ops.OrderBy, error)
- func (o *Ordering) Inputs() []ops.Operator
- func (o *Ordering) SetInputs(operators []ops.Operator)
- func (o *Ordering) ShortDescription() string
- type ProjExpr
- type Projection
- func (p *Projection) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (p *Projection) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (p *Projection) AllOffsets() (cols []int)
- func (p *Projection) Clone(inputs []ops.Operator) ops.Operator
- func (p *Projection) Compact(ctx *plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
- func (p *Projection) Description() ops.OpDescription
- func (p *Projection) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (p *Projection) GetOrdering() ([]ops.OrderBy, error)
- func (p *Projection) Inputs() []ops.Operator
- func (p *Projection) SetInputs(operators []ops.Operator)
- func (p *Projection) ShortDescription() string
- type QueryGraph
- func (QueryGraph) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (qg *QueryGraph) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (qg *QueryGraph) Clone([]ops.Operator) ops.Operator
- func (qg *QueryGraph) Description() ops.OpDescription
- func (QueryGraph) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (qg *QueryGraph) GetOrdering() ([]ops.OrderBy, error)
- func (qg *QueryGraph) GetPredicates(lhs, rhs semantics.TableSet) []sqlparser.Expr
- func (QueryGraph) Inputs() []ops.Operator
- func (qg *QueryGraph) Introduces() semantics.TableSet
- func (QueryGraph) SetInputs(ops []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) AggrRewriter(ctx *plancontext.PlanningContext) *AggrRewriter
- func (qp *QueryProjection) AggregationExpressions(ctx *plancontext.PlanningContext) (out []Aggr, err error)
- func (qp *QueryProjection) AlignGroupByAndOrderBy(ctx *plancontext.PlanningContext) bool
- func (qp *QueryProjection) FindSelectExprIndexForExpr(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (*int, *sqlparser.AliasedExpr)
- func (qp *QueryProjection) GetColumnCount() int
- func (qp *QueryProjection) GetGrouping() []GroupBy
- func (qp *QueryProjection) GetSimplifiedExpr(e sqlparser.Expr) sqlparser.Expr
- func (qp *QueryProjection) NeedsAggregation() bool
- func (qp *QueryProjection) NeedsDistinct() bool
- func (qp *QueryProjection) NeedsProjecting(ctx *plancontext.PlanningContext, ...) (needsVtGateEval bool, expressions []sqlparser.Expr, colNames []string, ...)
- func (qp *QueryProjection) OldAlignGroupByAndOrderBy(ctx *plancontext.PlanningContext)
- type QueryTable
- type Route
- func (r *Route) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (r *Route) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (r *Route) Clone(inputs []ops.Operator) ops.Operator
- func (r *Route) Cost() int
- func (r *Route) Description() ops.OpDescription
- func (r *Route) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (r *Route) GetOrdering() ([]ops.OrderBy, error)
- func (r *Route) Inputs() []ops.Operator
- func (r *Route) IsSingleShard() bool
- func (r *Route) SetInputs(ops []ops.Operator)
- func (r *Route) ShortDescription() string
- func (r *Route) TablesUsed() []string
- type RouteOrdering
- type Routing
- type SelectExpr
- type SequenceRouting
- func (sr *SequenceRouting) Clone() Routing
- func (sr *SequenceRouting) Cost() int
- func (sr *SequenceRouting) Keyspace() *vindexes.Keyspace
- func (sr *SequenceRouting) OpCode() engine.Opcode
- func (sr *SequenceRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
- 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) ResetRoutingLogic(ctx *plancontext.PlanningContext) (Routing, error)
- func (tr *ShardedRouting) SelectedVindex() vindexes.Vindex
- func (tr *ShardedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
- func (tr *ShardedRouting) VindexExpressions() []sqlparser.Expr
- type SubQuery
- func (SubQuery) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (SubQuery) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (s *SubQuery) Clone(inputs []ops.Operator) ops.Operator
- func (s *SubQuery) Description() ops.OpDescription
- func (SubQuery) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (s *SubQuery) GetOrdering() ([]ops.OrderBy, error)
- func (s *SubQuery) Inputs() []ops.Operator
- func (s *SubQuery) SetInputs(ops []ops.Operator)
- func (s *SubQuery) ShortDescription() string
- type SubQueryInner
- func (SubQueryInner) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (SubQueryInner) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (s *SubQueryInner) Clone(inputs []ops.Operator) ops.Operator
- func (s *SubQueryInner) Description() ops.OpDescription
- func (SubQueryInner) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (s *SubQueryInner) GetOrdering() ([]ops.OrderBy, error)
- func (s *SubQueryInner) Inputs() []ops.Operator
- func (s *SubQueryInner) SetInputs(ops []ops.Operator)
- func (s *SubQueryInner) ShortDescription() string
- type SubQueryOp
- func (SubQueryOp) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (SubQueryOp) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (s *SubQueryOp) Clone(inputs []ops.Operator) ops.Operator
- func (s *SubQueryOp) Description() ops.OpDescription
- func (SubQueryOp) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (s *SubQueryOp) GetOrdering() ([]ops.OrderBy, error)
- func (s *SubQueryOp) Inputs() []ops.Operator
- func (s *SubQueryOp) SetInputs(ops []ops.Operator)
- func (s *SubQueryOp) ShortDescription() string
- type Table
- func (to *Table) AddCol(col *sqlparser.ColName)
- func (to *Table) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (to *Table) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (to *Table) Clone([]ops.Operator) ops.Operator
- func (to *Table) Description() ops.OpDescription
- func (to *Table) GetColNames() []*sqlparser.ColName
- func (to *Table) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (to *Table) GetOrdering() ([]ops.OrderBy, error)
- func (Table) Inputs() []ops.Operator
- func (to *Table) Introduces() semantics.TableSet
- func (Table) SetInputs(ops []ops.Operator)
- func (to *Table) ShortDescription() string
- func (to *Table) TablesUsed() []string
- type TableIDIntroducer
- type TableUser
- type TargetedRouting
- func (tr *TargetedRouting) Clone() Routing
- func (tr *TargetedRouting) Cost() int
- func (tr *TargetedRouting) Keyspace() *vindexes.Keyspace
- func (tr *TargetedRouting) OpCode() engine.Opcode
- func (tr *TargetedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
- type UnexploredExpression
- type Union
- func (Union) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (u *Union) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (u *Union) Clone(inputs []ops.Operator) ops.Operator
- func (u *Union) Compact(*plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
- func (u *Union) Description() ops.OpDescription
- func (Union) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (u *Union) GetOrdering() ([]ops.OrderBy, error)
- func (u *Union) GetSelectFor(source int) (*sqlparser.Select, error)
- func (u *Union) Inputs() []ops.Operator
- func (u *Union) NoLHSTableSet()
- func (u *Union) SetInputs(ops []ops.Operator)
- func (u *Union) ShortDescription() string
- type Update
- func (Update) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
- func (Update) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
- func (u *Update) Clone([]ops.Operator) ops.Operator
- func (u *Update) Description() ops.OpDescription
- func (Update) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (u *Update) GetOrdering() ([]ops.OrderBy, error)
- func (Update) Inputs() []ops.Operator
- func (u *Update) Introduces() semantics.TableSet
- func (Update) SetInputs(ops []ops.Operator)
- func (u *Update) ShortDescription() string
- func (u *Update) TablesUsed() []string
- type Vindex
- func (v *Vindex) AddCol(col *sqlparser.ColName)
- func (v *Vindex) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, ...) (ops.Operator, int, error)
- func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
- func (v *Vindex) CheckValid() error
- func (v *Vindex) Clone([]ops.Operator) ops.Operator
- func (v *Vindex) Description() ops.OpDescription
- func (v *Vindex) GetColNames() []*sqlparser.ColName
- func (v *Vindex) GetColumns() ([]*sqlparser.AliasedExpr, error)
- func (v *Vindex) GetOrdering() ([]ops.OrderBy, error)
- func (Vindex) Inputs() []ops.Operator
- func (v *Vindex) Introduces() semantics.TableSet
- func (Vindex) SetInputs(ops []ops.Operator)
- func (v *Vindex) ShortDescription() string
- func (v *Vindex) TablesUsed() []string
- type VindexOption
- type VindexPlusPredicates
- type VindexTable
Constants ¶
const VindexUnsupported = "WHERE clause for vindex function must be of the form id = <val> or id in(<val>,...)"
Variables ¶
This section is empty.
Functions ¶
func AddPredicate ¶
func CompareRefInt ¶
CompareRefInt compares two references of integers. In case either one is nil, it is considered to be smaller
func IsTableSchemaOrName ¶ added in v0.17.0
func Merge ¶ added in v0.17.0
func Merge(ctx *plancontext.PlanningContext, lhs, rhs ops.Operator, joinPredicates []sqlparser.Expr, m merger) (ops.Operator, error)
Merge checks whether two operators can be merged into a single one. If they can be merged, a new operator with the merged routing is returned If they cannot be merged, nil is returned.
func NotImplementedSchemaInfoResolver ¶ added in v0.17.0
func PlanQuery ¶
func PlanQuery(ctx *plancontext.PlanningContext, stmt sqlparser.Statement) (ops.Operator, error)
PlanQuery creates a query plan for a given SQL statement
func QualifiedIdentifier ¶
func QualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) string
func QualifiedTableName ¶
func QualifiedTableNames ¶
func RemovePredicate ¶
func RemovePredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, op ops.Operator) (ops.Operator, error)
RemovePredicate is used when we turn a predicate into a plan operator, and the predicate needs to be removed as an AST construct
func SingleQualifiedIdentifier ¶
func SingleQualifiedIdentifier(ks *vindexes.Keyspace, i sqlparser.IdentifierCS) []string
func SortAggregations ¶
func SortAggregations(a []Aggr)
func SortGrouping ¶
func SortGrouping(a []GroupBy)
func TablesUsed ¶
func ToSQL ¶
func ToSQL(ctx *plancontext.PlanningContext, op ops.Operator) (sqlparser.SelectStatement, error)
Types ¶
type Aggr ¶
type Aggr struct { Original *sqlparser.AliasedExpr Func sqlparser.AggrFunc 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 Index *int Distinct bool // the offsets point to columns on the same aggregator ColOffset int WSOffset int }
Aggr encodes all information needed for aggregation functions
func NewAggr ¶ added in v0.17.0
func NewAggr(opCode opcode.AggregateOpcode, f sqlparser.AggrFunc, original *sqlparser.AliasedExpr, alias string) Aggr
func (Aggr) GetCollation ¶ added in v0.17.0
func (aggr Aggr) GetCollation(ctx *plancontext.PlanningContext) collations.ID
func (Aggr) NeedWeightString ¶ added in v0.17.0
func (aggr Aggr) NeedWeightString(ctx *plancontext.PlanningContext) bool
type AggrRewriter ¶
type AggrRewriter struct { Err error // contains filtered or unexported fields }
func (*AggrRewriter) RewriteDown ¶
RewriteDown stops the walker from entering inside aggregation functions
type Aggregator ¶ added in v0.17.0
type Aggregator struct { Source ops.Operator Columns []*sqlparser.AliasedExpr Grouping []GroupBy Aggregations []Aggr // 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 // TableID will be non-nil for derived tables TableID *semantics.TableSet Alias string }
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 ¶ added in v0.17.0
func (a *Aggregator) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Aggregator) AddPredicate ¶ added in v0.17.0
func (a *Aggregator) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Aggregator) Clone ¶ added in v0.17.0
func (a *Aggregator) Clone(inputs []ops.Operator) ops.Operator
func (*Aggregator) Description ¶ added in v0.17.0
func (a *Aggregator) Description() ops.OpDescription
func (*Aggregator) GetColumns ¶ added in v0.17.0
func (a *Aggregator) GetColumns() (columns []*sqlparser.AliasedExpr, err error)
func (*Aggregator) GetOrdering ¶ added in v0.17.0
func (a *Aggregator) GetOrdering() ([]ops.OrderBy, error)
func (*Aggregator) Inputs ¶ added in v0.17.0
func (a *Aggregator) Inputs() []ops.Operator
func (*Aggregator) SetInputs ¶ added in v0.17.0
func (a *Aggregator) SetInputs(operators []ops.Operator)
func (*Aggregator) ShortDescription ¶ added in v0.17.0
func (a *Aggregator) ShortDescription() string
type AnyShardRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (rr *AnyShardRouting) AlternateInKeyspace(keyspace *vindexes.Keyspace) *Route
func (*AnyShardRouting) Clone ¶ added in v0.17.0
func (rr *AnyShardRouting) Clone() Routing
func (*AnyShardRouting) Cost ¶ added in v0.17.0
func (rr *AnyShardRouting) Cost() int
func (*AnyShardRouting) Keyspace ¶ added in v0.17.0
func (rr *AnyShardRouting) Keyspace() *vindexes.Keyspace
func (*AnyShardRouting) OpCode ¶ added in v0.17.0
func (rr *AnyShardRouting) OpCode() engine.Opcode
func (*AnyShardRouting) UpdateRoutingParams ¶ added in v0.17.0
func (rr *AnyShardRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
type ApplyJoin ¶
type ApplyJoin struct {
LHS, RHS ops.Operator
// LeftJoin will be true in the case of an outer join
LeftJoin bool
// JoinCols are the columns from the LHS used for the join.
// These are the same columns pushed on the LHS that are now used in the Vars field
LHSColumns []*sqlparser.ColName
// Before offset planning
Predicate sqlparser.Expr
// ColumnsAST keeps track of what AST expression is represented in the Columns array
ColumnsAST []JoinColumn
// JoinPredicates are join predicates that have been broken up into left hand side and right hand side parts.
JoinPredicates []JoinColumn
// 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 (*ApplyJoin) AddColumn ¶
func (a *ApplyJoin) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*ApplyJoin) AddJoinPredicate ¶
func (a *ApplyJoin) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
func (*ApplyJoin) AddPredicate ¶
func (a *ApplyJoin) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*ApplyJoin) Description ¶ added in v0.17.0
func (a *ApplyJoin) Description() ops.OpDescription
func (*ApplyJoin) GetColumns ¶ added in v0.17.0
func (a *ApplyJoin) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*ApplyJoin) GetOrdering ¶ added in v0.17.0
func (*ApplyJoin) ShortDescription ¶ added in v0.17.0
type ColNameColumns ¶
type CorrelatedSubQueryOp ¶
type CorrelatedSubQueryOp struct {
func (CorrelatedSubQueryOp) AddColumn ¶
func (CorrelatedSubQueryOp) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (CorrelatedSubQueryOp) AddPredicate ¶
func (CorrelatedSubQueryOp) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*CorrelatedSubQueryOp) Clone ¶
func (c *CorrelatedSubQueryOp) Clone(inputs []ops.Operator) ops.Operator
Clone implements the Operator interface
func (*CorrelatedSubQueryOp) Description ¶ added in v0.17.0
func (c *CorrelatedSubQueryOp) Description() ops.OpDescription
func (CorrelatedSubQueryOp) GetColumns ¶ added in v0.17.0
func (CorrelatedSubQueryOp) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*CorrelatedSubQueryOp) GetOrdering ¶ added in v0.17.0
func (c *CorrelatedSubQueryOp) GetOrdering() ([]ops.OrderBy, error)
func (*CorrelatedSubQueryOp) Inputs ¶
func (c *CorrelatedSubQueryOp) Inputs() []ops.Operator
Inputs implements the Operator interface
func (*CorrelatedSubQueryOp) SetInputs ¶ added in v0.17.0
func (c *CorrelatedSubQueryOp) SetInputs(ops []ops.Operator)
SetInputs implements the Operator interface
func (*CorrelatedSubQueryOp) ShortDescription ¶ added in v0.17.0
func (c *CorrelatedSubQueryOp) ShortDescription() string
type Delete ¶
type Delete struct { QTable *QueryTable VTable *vindexes.Table OwnedVindexQuery string AST *sqlparser.Delete // contains filtered or unexported fields }
func (Delete) AddColumn ¶
func (Delete) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (Delete) AddPredicate ¶
func (Delete) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*Delete) Description ¶ added in v0.17.0
func (d *Delete) Description() ops.OpDescription
func (Delete) GetColumns ¶ added in v0.17.0
func (Delete) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Delete) Introduces ¶
Introduces implements the PhysicalOperator interface
func (*Delete) ShortDescription ¶ added in v0.17.0
func (*Delete) TablesUsed ¶
type Derived ¶
type Derived struct { Source ops.Operator TableId semantics.TableSet // QP contains the QueryProjection for this op QP *QueryProjection Query sqlparser.SelectStatement Alias string ColumnAliases sqlparser.Columns // Columns needed to feed other plans Columns []*sqlparser.ColName ColumnsOffset []int }
func (*Derived) AddColumn ¶
func (d *Derived) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Derived) AddPredicate ¶
func (d *Derived) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Derived) Description ¶ added in v0.17.0
func (d *Derived) Description() ops.OpDescription
func (*Derived) GetColumns ¶ added in v0.17.0
func (d *Derived) GetColumns() (exprs []*sqlparser.AliasedExpr, err error)
func (*Derived) GetOrdering ¶ added in v0.17.0
func (*Derived) IsMergeable ¶
func (d *Derived) 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 (*Derived) ShortDescription ¶ added in v0.17.0
type Distinct ¶ added in v0.17.0
type Distinct struct { Source ops.Operator QP *QueryProjection Pushed bool // When offset planning, we'll fill in this field Columns []engine.CheckCol Truncate int }
func (*Distinct) AddColumn ¶ added in v0.17.0
func (d *Distinct) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, reuseExisting, addToGroupBy bool) (ops.Operator, int, error)
func (*Distinct) AddPredicate ¶ added in v0.17.0
func (d *Distinct) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Distinct) Description ¶ added in v0.17.0
func (d *Distinct) Description() ops.OpDescription
func (*Distinct) GetColumns ¶ added in v0.17.0
func (d *Distinct) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Distinct) GetOrdering ¶ added in v0.17.0
func (*Distinct) ShortDescription ¶ added in v0.17.0
type DualRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (dr *DualRouting) Clone() Routing
func (*DualRouting) Cost ¶ added in v0.17.0
func (dr *DualRouting) Cost() int
func (*DualRouting) Keyspace ¶ added in v0.17.0
func (dr *DualRouting) Keyspace() *vindexes.Keyspace
func (*DualRouting) OpCode ¶ added in v0.17.0
func (dr *DualRouting) OpCode() engine.Opcode
func (*DualRouting) UpdateRoutingParams ¶ added in v0.17.0
func (dr *DualRouting) UpdateRoutingParams(*plancontext.PlanningContext, *engine.RoutingParameters) error
type Eval ¶ added in v0.17.0
type Eval struct { Expr sqlparser.Expr EExpr evalengine.Expr }
Eval is used for expressions that have to be evaluated in the vtgate using the evalengine
type Filter ¶
type Filter struct { Source ops.Operator Predicates []sqlparser.Expr // FinalPredicate is the evalengine expression that will finally be used. // It contains the ANDed predicates in Predicates, with ColName:s replaced by Offset:s FinalPredicate evalengine.Expr }
func (*Filter) AddColumn ¶
func (f *Filter) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, reuseExisting, addToGroupBy bool) (ops.Operator, int, error)
func (*Filter) AddPredicate ¶
func (f *Filter) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Filter) Compact ¶
func (f *Filter) Compact(*plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
func (*Filter) Description ¶ added in v0.17.0
func (f *Filter) Description() ops.OpDescription
func (*Filter) GetColumns ¶ added in v0.17.0
func (f *Filter) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Filter) ShortDescription ¶ added in v0.17.0
type Generate ¶ added in v0.17.0
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 simplified expressions is the "unaliased expression". // In the following query, the group by has the inner expression // `x` and the `SimplifiedExpr` is `table.col + 10`: // select table.col + 10 as x, count(*) from tbl group by x SimplifiedExpr 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 // contains filtered or unexported fields }
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 ¶ added in v0.17.0
func NewGroupBy(inner, simplified sqlparser.Expr, aliasedExpr *sqlparser.AliasedExpr) GroupBy
NewGroupBy creates a new group by from the given fields.
func (GroupBy) AsAliasedExpr ¶
func (b GroupBy) AsAliasedExpr() *sqlparser.AliasedExpr
type Horizon ¶
type Horizon struct { Source ops.Operator Select sqlparser.SelectStatement QP *QueryProjection }
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(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
func (*Horizon) AddPredicate ¶
func (h *Horizon) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Horizon) Description ¶ added in v0.17.0
func (h *Horizon) Description() ops.OpDescription
func (*Horizon) GetColumns ¶ added in v0.17.0
func (h *Horizon) GetColumns() (exprs []*sqlparser.AliasedExpr, err error)
func (*Horizon) GetOrdering ¶ added in v0.17.0
func (*Horizon) ShortDescription ¶ added in v0.17.0
type InfoSchemaRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (isr *InfoSchemaRouting) Clone() Routing
func (*InfoSchemaRouting) Cost ¶ added in v0.17.0
func (isr *InfoSchemaRouting) Cost() int
func (*InfoSchemaRouting) Keyspace ¶ added in v0.17.0
func (isr *InfoSchemaRouting) Keyspace() *vindexes.Keyspace
func (*InfoSchemaRouting) OpCode ¶ added in v0.17.0
func (isr *InfoSchemaRouting) OpCode() engine.Opcode
func (*InfoSchemaRouting) UpdateRoutingParams ¶ added in v0.17.0
func (isr *InfoSchemaRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
type Insert ¶ added in v0.17.0
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 // ForceNonStreaming when true, select first then insert, this is to avoid locking rows by select for insert. ForceNonStreaming 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 // Insert using select query will have select plan as input operator for the insert operation. Input ops.Operator // contains filtered or unexported fields }
Insert represents an insert operation on a table.
func (Insert) AddColumn ¶ added in v0.17.0
func (Insert) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (Insert) AddPredicate ¶ added in v0.17.0
func (Insert) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*Insert) Description ¶ added in v0.17.0
func (i *Insert) Description() ops.OpDescription
func (Insert) GetColumns ¶ added in v0.17.0
func (Insert) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Insert) ShortDescription ¶ added in v0.17.0
func (*Insert) TablesUsed ¶ added in v0.17.0
type Join ¶
type Join struct {
LHS, RHS ops.Operator
Predicate sqlparser.Expr
LeftJoin bool
// 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, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (*Join) AddJoinPredicate ¶
func (j *Join) AddJoinPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
func (*Join) AddPredicate ¶
func (j *Join) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Join) Compact ¶
func (j *Join) Compact(ctx *plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
func (*Join) Description ¶ added in v0.17.0
func (j *Join) Description() ops.OpDescription
func (Join) GetColumns ¶ added in v0.17.0
func (Join) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Join) ShortDescription ¶ added in v0.17.0
type JoinColumn ¶ added in v0.17.0
type JoinColumn struct { Original *sqlparser.AliasedExpr // this is the original expression being passed through BvNames []string // the BvNames and LHSCols line up LHSExprs []sqlparser.Expr RHSExpr sqlparser.Expr GroupBy bool // if this is true, we need to push this down to our inputs with addToGroupBy set to true }
JoinColumn is where we store information about columns passing through the join operator It can be in one of three possible configurations:
- Pure left We are projecting a column that comes from the left. The RHSExpr will be nil for these
- Pure right We are projecting a column that comes from the right. The LHSExprs will be empty for these
- Mix of data from left and right Here we need to transmit columns from the LHS to the RHS, so they can be used for the result of this expression that is using data from both sides. All fields will be used for these
func BreakExpressionInLHSandRHS ¶
func BreakExpressionInLHSandRHS( ctx *plancontext.PlanningContext, expr sqlparser.Expr, lhs semantics.TableSet, ) (col JoinColumn, err error)
BreakExpressionInLHSandRHS takes an expression and extracts the parts that are coming from one of the sides into `ColName`s that are needed
func (JoinColumn) IsMixedLeftAndRight ¶ added in v0.17.0
func (jc JoinColumn) IsMixedLeftAndRight() bool
func (JoinColumn) IsPureLeft ¶ added in v0.17.0
func (jc JoinColumn) IsPureLeft() bool
func (JoinColumn) IsPureRight ¶ added in v0.17.0
func (jc JoinColumn) IsPureRight() bool
type Limit ¶ added in v0.17.0
type Limit struct { Source ops.Operator AST *sqlparser.Limit // Pushed marks whether the limit has been pushed down to the inputs but still need to keep the operator around. // For example, `select * from user order by id limit 10`. Even after we push the limit to the route, we need a limit on top // since it is a scatter. Pushed bool }
func (*Limit) AddColumn ¶ added in v0.17.0
func (l *Limit) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, reuseExisting, addToGroupBy bool) (ops.Operator, int, error)
func (*Limit) AddPredicate ¶ added in v0.17.0
func (l *Limit) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Limit) Description ¶ added in v0.17.0
func (l *Limit) Description() ops.OpDescription
func (*Limit) GetColumns ¶ added in v0.17.0
func (l *Limit) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Limit) ShortDescription ¶ added in v0.17.0
type NoneRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (n *NoneRouting) Clone() Routing
func (*NoneRouting) Cost ¶ added in v0.17.0
func (n *NoneRouting) Cost() int
func (*NoneRouting) Keyspace ¶ added in v0.17.0
func (n *NoneRouting) Keyspace() *vindexes.Keyspace
func (*NoneRouting) OpCode ¶ added in v0.17.0
func (n *NoneRouting) OpCode() engine.Opcode
func (*NoneRouting) UpdateRoutingParams ¶ added in v0.17.0
func (n *NoneRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
type Offset ¶ added in v0.17.0
Offset is used when we are only passing through data from an incoming column
type Ordering ¶ added in v0.17.0
type Ordering struct { Source ops.Operator Offset []int WOffset []int Order []ops.OrderBy ResultColumns int }
func (*Ordering) AddColumn ¶ added in v0.17.0
func (o *Ordering) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, reuseExisting, addToGroupBy bool) (ops.Operator, int, error)
func (*Ordering) AddPredicate ¶ added in v0.17.0
func (o *Ordering) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Ordering) Description ¶ added in v0.17.0
func (o *Ordering) Description() ops.OpDescription
func (*Ordering) GetColumns ¶ added in v0.17.0
func (o *Ordering) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Ordering) GetOrdering ¶ added in v0.17.0
func (*Ordering) ShortDescription ¶ added in v0.17.0
type Projection ¶ added in v0.17.0
type Projection struct { Source ops.Operator // Columns contain the expressions as viewed from the outside of this operator Columns []*sqlparser.AliasedExpr // Projections will contain the actual evaluations we need to // do if this operator is still above a route after optimisation Projections []ProjExpr // TableID will be non-nil for derived tables TableID *semantics.TableSet Alias string 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 ¶ added in v0.17.0
func (p *Projection) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Projection) AddPredicate ¶ added in v0.17.0
func (p *Projection) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Projection) AllOffsets ¶ added in v0.17.0
func (p *Projection) AllOffsets() (cols []int)
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 ¶ added in v0.17.0
func (p *Projection) Clone(inputs []ops.Operator) ops.Operator
func (*Projection) Compact ¶ added in v0.17.0
func (p *Projection) Compact(ctx *plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
func (*Projection) Description ¶ added in v0.17.0
func (p *Projection) Description() ops.OpDescription
func (*Projection) GetColumns ¶ added in v0.17.0
func (p *Projection) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Projection) GetOrdering ¶ added in v0.17.0
func (p *Projection) GetOrdering() ([]ops.OrderBy, error)
func (*Projection) Inputs ¶ added in v0.17.0
func (p *Projection) Inputs() []ops.Operator
func (*Projection) SetInputs ¶ added in v0.17.0
func (p *Projection) SetInputs(operators []ops.Operator)
func (*Projection) ShortDescription ¶ added in v0.17.0
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, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (*QueryGraph) AddPredicate ¶
func (qg *QueryGraph) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*QueryGraph) Clone ¶
func (qg *QueryGraph) Clone([]ops.Operator) ops.Operator
Clone implements the Operator interface
func (*QueryGraph) Description ¶ added in v0.17.0
func (qg *QueryGraph) Description() ops.OpDescription
func (QueryGraph) GetColumns ¶ added in v0.17.0
func (QueryGraph) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*QueryGraph) GetOrdering ¶ added in v0.17.0
func (qg *QueryGraph) GetOrdering() ([]ops.OrderBy, error)
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) Introduces ¶
func (qg *QueryGraph) Introduces() semantics.TableSet
Introduces implements the TableIDIntroducer interface
func (*QueryGraph) ShortDescription ¶ added in v0.17.0
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 OrderExprs []ops.OrderBy HasStar bool // AddedColumn keeps a counter for expressions added to solve HAVING expressions the user is not selecting AddedColumn int // TODO Remove once all horizon planning is done on the operators CanPushDownSorting bool // contains filtered or unexported fields }
QueryProjection contains the information about the projections, group by and order by expressions used to do horizon planning.
func CreateQPFromSelect ¶
func CreateQPFromSelect(ctx *plancontext.PlanningContext, sel *sqlparser.Select) (*QueryProjection, error)
CreateQPFromSelect creates the QueryProjection for the input *sqlparser.Select
func CreateQPFromUnion ¶
func CreateQPFromUnion(ctx *plancontext.PlanningContext, union *sqlparser.Union) (*QueryProjection, error)
CreateQPFromUnion creates the QueryProjection for the input *sqlparser.Union
func (*QueryProjection) AddGroupBy ¶
func (qp *QueryProjection) AddGroupBy(by GroupBy)
AddGroupBy does just that
func (*QueryProjection) AggrRewriter ¶
func (qp *QueryProjection) AggrRewriter(ctx *plancontext.PlanningContext) *AggrRewriter
AggrRewriter extracts
func (*QueryProjection) AggregationExpressions ¶
func (qp *QueryProjection) AggregationExpressions(ctx *plancontext.PlanningContext) (out []Aggr, err error)
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, *sqlparser.AliasedExpr)
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) GetSimplifiedExpr ¶
func (qp *QueryProjection) GetSimplifiedExpr(e sqlparser.Expr) sqlparser.Expr
GetSimplifiedExpr takes an expression used in ORDER BY or GROUP BY, and returns an expression that is simpler to evaluate
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) NeedsProjecting ¶ added in v0.16.1
func (qp *QueryProjection) NeedsProjecting( ctx *plancontext.PlanningContext, pusher func(expr *sqlparser.AliasedExpr) (int, error), ) (needsVtGateEval bool, expressions []sqlparser.Expr, colNames []string, err error)
NeedsProjecting returns true if we have projections that need to be evaluated at the vtgate level and can't be pushed down to MySQL
func (*QueryProjection) OldAlignGroupByAndOrderBy ¶ added in v0.17.0
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 ops.Operator // Routes that have been merged into this one. MergedWith []*Route Routing Routing Ordering []RouteOrdering ResultColumns int }
func (*Route) AddColumn ¶
func (r *Route) AddColumn(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Route) AddPredicate ¶
func (r *Route) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Route) Description ¶ added in v0.17.0
func (r *Route) Description() ops.OpDescription
func (*Route) GetColumns ¶ added in v0.17.0
func (r *Route) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Route) IsSingleShard ¶
func (*Route) ShortDescription ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
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) error // 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 ¶ added in v0.17.0
func UpdateRoutingLogic(ctx *plancontext.PlanningContext, expr sqlparser.Expr, r Routing) (Routing, error)
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 ¶ added in v0.17.0
type SequenceRouting struct {
// contains filtered or unexported fields
}
func (*SequenceRouting) Clone ¶ added in v0.17.0
func (sr *SequenceRouting) Clone() Routing
func (*SequenceRouting) Cost ¶ added in v0.17.0
func (sr *SequenceRouting) Cost() int
func (*SequenceRouting) Keyspace ¶ added in v0.17.0
func (sr *SequenceRouting) Keyspace() *vindexes.Keyspace
func (*SequenceRouting) OpCode ¶ added in v0.17.0
func (sr *SequenceRouting) OpCode() engine.Opcode
func (*SequenceRouting) UpdateRoutingParams ¶ added in v0.17.0
func (sr *SequenceRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
type ShardedRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (tr *ShardedRouting) Clone() Routing
func (*ShardedRouting) Cost ¶ added in v0.17.0
func (tr *ShardedRouting) Cost() int
func (*ShardedRouting) Keyspace ¶ added in v0.17.0
func (tr *ShardedRouting) Keyspace() *vindexes.Keyspace
func (*ShardedRouting) OpCode ¶ added in v0.17.0
func (tr *ShardedRouting) OpCode() engine.Opcode
func (*ShardedRouting) PickBestAvailableVindex ¶ added in v0.17.0
func (tr *ShardedRouting) PickBestAvailableVindex()
PickBestAvailableVindex goes over the available vindexes for this route and picks the best one available.
func (*ShardedRouting) ResetRoutingLogic ¶ added in v0.17.0
func (tr *ShardedRouting) ResetRoutingLogic(ctx *plancontext.PlanningContext) (Routing, error)
func (*ShardedRouting) SelectedVindex ¶ added in v0.17.0
func (tr *ShardedRouting) SelectedVindex() vindexes.Vindex
func (*ShardedRouting) UpdateRoutingParams ¶ added in v0.17.0
func (tr *ShardedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
func (*ShardedRouting) VindexExpressions ¶ added in v0.17.0
func (tr *ShardedRouting) VindexExpressions() []sqlparser.Expr
type SubQuery ¶
type SubQuery struct { Outer ops.Operator Inner []*SubQueryInner // contains filtered or unexported fields }
SubQuery stores the information about subquery
func (SubQuery) AddColumn ¶
func (SubQuery) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (SubQuery) AddPredicate ¶
func (SubQuery) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*SubQuery) Description ¶ added in v0.17.0
func (s *SubQuery) Description() ops.OpDescription
func (SubQuery) GetColumns ¶ added in v0.17.0
func (SubQuery) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*SubQuery) GetOrdering ¶ added in v0.17.0
func (*SubQuery) ShortDescription ¶ added in v0.17.0
type SubQueryInner ¶
type SubQueryInner struct { // Inner is the Operator inside the parenthesis of the subquery. // i.e: select (select 1 union select 1), the Inner here would be // of type Concatenate since we have a Union. Inner ops.Operator // ExtractedSubquery contains all information we need about this subquery ExtractedSubquery *sqlparser.ExtractedSubquery // contains filtered or unexported fields }
SubQueryInner stores the subquery information for a select statement
func (SubQueryInner) AddColumn ¶
func (SubQueryInner) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (SubQueryInner) AddPredicate ¶
func (SubQueryInner) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*SubQueryInner) Clone ¶
func (s *SubQueryInner) Clone(inputs []ops.Operator) ops.Operator
Clone implements the Operator interface
func (*SubQueryInner) Description ¶ added in v0.17.0
func (s *SubQueryInner) Description() ops.OpDescription
func (SubQueryInner) GetColumns ¶ added in v0.17.0
func (SubQueryInner) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*SubQueryInner) GetOrdering ¶ added in v0.17.0
func (s *SubQueryInner) GetOrdering() ([]ops.OrderBy, error)
func (*SubQueryInner) Inputs ¶
func (s *SubQueryInner) Inputs() []ops.Operator
Inputs implements the Operator interface
func (*SubQueryInner) SetInputs ¶ added in v0.17.0
func (s *SubQueryInner) SetInputs(ops []ops.Operator)
SetInputs implements the Operator interface
func (*SubQueryInner) ShortDescription ¶ added in v0.17.0
func (s *SubQueryInner) ShortDescription() string
type SubQueryOp ¶
type SubQueryOp struct {
Outer, Inner ops.Operator
Extracted *sqlparser.ExtractedSubquery
// contains filtered or unexported fields
}
func (SubQueryOp) AddColumn ¶
func (SubQueryOp) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (SubQueryOp) AddPredicate ¶
func (SubQueryOp) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*SubQueryOp) Clone ¶
func (s *SubQueryOp) Clone(inputs []ops.Operator) ops.Operator
Clone implements the Operator interface
func (*SubQueryOp) Description ¶ added in v0.17.0
func (s *SubQueryOp) Description() ops.OpDescription
func (SubQueryOp) GetColumns ¶ added in v0.17.0
func (SubQueryOp) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*SubQueryOp) GetOrdering ¶ added in v0.17.0
func (s *SubQueryOp) GetOrdering() ([]ops.OrderBy, error)
func (*SubQueryOp) Inputs ¶
func (s *SubQueryOp) Inputs() []ops.Operator
Inputs implements the Operator interface
func (*SubQueryOp) SetInputs ¶ added in v0.17.0
func (s *SubQueryOp) SetInputs(ops []ops.Operator)
SetInputs implements the Operator interface
func (*SubQueryOp) ShortDescription ¶ added in v0.17.0
func (s *SubQueryOp) ShortDescription() string
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(ctx *plancontext.PlanningContext, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Table) AddPredicate ¶
func (to *Table) AddPredicate(_ *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the PhysicalOperator interface
func (*Table) Description ¶ added in v0.17.0
func (to *Table) Description() ops.OpDescription
func (*Table) GetColNames ¶ added in v0.17.0
func (*Table) GetColumns ¶
func (to *Table) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Table) Introduces ¶
Introduces implements the PhysicalOperator interface
func (*Table) ShortDescription ¶ added in v0.17.0
func (*Table) TablesUsed ¶
type TableIDIntroducer ¶
TableIDIntroducer is used to signal that this operator introduces data from a new source
type TableUser ¶
type TableUser interface {
TablesUsed() []string
}
TableUser is used to signal that this operator directly interacts with one or more tables
type TargetedRouting ¶ added in v0.17.0
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 ¶ added in v0.17.0
func (tr *TargetedRouting) Clone() Routing
func (*TargetedRouting) Cost ¶ added in v0.17.0
func (tr *TargetedRouting) Cost() int
func (*TargetedRouting) Keyspace ¶ added in v0.17.0
func (tr *TargetedRouting) Keyspace() *vindexes.Keyspace
func (*TargetedRouting) OpCode ¶ added in v0.17.0
func (tr *TargetedRouting) OpCode() engine.Opcode
func (*TargetedRouting) UpdateRoutingParams ¶ added in v0.17.0
func (tr *TargetedRouting) UpdateRoutingParams(_ *plancontext.PlanningContext, rp *engine.RoutingParameters) error
type UnexploredExpression ¶ added in v0.17.0
UnexploredExpression is used before we have planned - one of two end results are possible for it
- we are able to push this projection under a route, and then this is not used at all - we'll just use the ColumnNames field of the Projection struct
- we have to evaluate this on the vtgate, and either it's just a copy from the input, or it's an evalengine expression that we have to evaluate
func (UnexploredExpression) GetExpr ¶ added in v0.17.0
func (po UnexploredExpression) GetExpr() sqlparser.Expr
type Union ¶
type Union struct { Sources []ops.Operator Distinct bool // TODO this should be removed. For now it's used to fail queries Ordering []ops.OrderBy // contains filtered or unexported fields }
func (Union) AddColumn ¶
func (Union) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (*Union) AddPredicate ¶
func (u *Union) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
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) Compact ¶
func (u *Union) Compact(*plancontext.PlanningContext) (ops.Operator, *rewrite.ApplyResult, error)
func (*Union) Description ¶ added in v0.17.0
func (u *Union) Description() ops.OpDescription
func (Union) GetColumns ¶ added in v0.17.0
func (Union) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Union) NoLHSTableSet ¶ added in v0.17.0
func (u *Union) NoLHSTableSet()
func (*Union) ShortDescription ¶ added in v0.17.0
type Update ¶
type Update struct { QTable *QueryTable VTable *vindexes.Table Assignments map[string]sqlparser.Expr ChangedVindexValues map[string]*engine.VindexValues OwnedVindexQuery string AST *sqlparser.Update // contains filtered or unexported fields }
func (Update) AddColumn ¶
func (Update) AddColumn(*plancontext.PlanningContext, *sqlparser.AliasedExpr, bool, bool) (ops.Operator, int, error)
AddColumn implements the Operator interface
func (Update) AddPredicate ¶
func (Update) AddPredicate(*plancontext.PlanningContext, sqlparser.Expr) (ops.Operator, error)
AddPredicate implements the Operator interface
func (*Update) Description ¶ added in v0.17.0
func (u *Update) Description() ops.OpDescription
func (Update) GetColumns ¶ added in v0.17.0
func (Update) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Update) Introduces ¶
Introduces implements the PhysicalOperator interface
func (*Update) ShortDescription ¶ added in v0.17.0
func (*Update) TablesUsed ¶
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, expr *sqlparser.AliasedExpr, _, addToGroupBy bool) (ops.Operator, int, error)
func (*Vindex) AddPredicate ¶
func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (ops.Operator, error)
func (*Vindex) CheckValid ¶
func (*Vindex) Description ¶ added in v0.17.0
func (v *Vindex) Description() ops.OpDescription
func (*Vindex) GetColNames ¶ added in v0.17.0
func (*Vindex) GetColumns ¶
func (v *Vindex) GetColumns() ([]*sqlparser.AliasedExpr, error)
func (*Vindex) Introduces ¶
Introduces implements the Operator interface
func (*Vindex) ShortDescription ¶ added in v0.17.0
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
Source Files ¶
- SQL_builder.go
- aggregation_pushing.go
- aggregator.go
- apply_join.go
- correlated_subquery.go
- delete.go
- derived.go
- distinct.go
- dml_planning.go
- expressions.go
- filter.go
- helpers.go
- horizon.go
- horizon_planning.go
- info_schema_planning.go
- insert.go
- join.go
- joins.go
- limit.go
- logical.go
- merging.go
- misc_routing.go
- offset_planning.go
- operator.go
- operator_funcs.go
- ordering.go
- projection.go
- querygraph.go
- queryprojection.go
- route.go
- route_planning.go
- sharded_routing.go
- subquery.go
- subquery_planning.go
- table.go
- union.go
- update.go
- vindex.go