abstract

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Concatenate added in v0.12.0

type Concatenate struct {
	Distinct    bool
	SelectStmts []*sqlparser.Select
	Sources     []LogicalOperator
	OrderBy     sqlparser.OrderBy
	Limit       *sqlparser.Limit
}

Concatenate represents a UNION ALL/DISTINCT.

func (*Concatenate) CheckValid added in v0.12.0

func (c *Concatenate) CheckValid() error

CheckValid implements the Operator interface

func (*Concatenate) Compact added in v0.12.0

Compact implements the Operator interface

func (*Concatenate) PushPredicate added in v0.12.0

func (c *Concatenate) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the Operator interface

func (*Concatenate) TableID added in v0.12.0

func (c *Concatenate) TableID() semantics.TableSet

TableID implements the Operator interface

func (*Concatenate) UnsolvedPredicates added in v0.12.0

func (c *Concatenate) UnsolvedPredicates(*semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type Derived added in v0.12.0

type Derived struct {
	Sel           sqlparser.SelectStatement
	Inner         LogicalOperator
	Alias         string
	ColumnAliases sqlparser.Columns
}

Derived represents a derived table in the query

func (*Derived) CheckValid added in v0.12.0

func (d *Derived) CheckValid() error

CheckValid implements the Operator interface

func (*Derived) Compact added in v0.12.0

Compact implements the Operator interface

func (*Derived) PushPredicate added in v0.12.0

func (d *Derived) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the Operator interface

func (*Derived) TableID added in v0.12.0

func (d *Derived) TableID() semantics.TableSet

TableID implements the Operator interface

func (*Derived) UnsolvedPredicates added in v0.12.0

func (d *Derived) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type Filter added in v0.13.0

type Filter struct {
	Source     LogicalOperator
	Predicates []sqlparser.Expr
}

func (*Filter) CheckValid added in v0.13.0

func (f *Filter) CheckValid() error

CheckValid implements the LogicalOperator interface

func (*Filter) Compact added in v0.13.0

func (f *Filter) Compact(semTable *semantics.SemTable) (LogicalOperator, error)

Compact implements the LogicalOperator interface

func (*Filter) PushPredicate added in v0.13.0

func (f *Filter) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the LogicalOperator interface

func (*Filter) TableID added in v0.13.0

func (f *Filter) TableID() semantics.TableSet

TableID implements the LogicalOperator interface

func (*Filter) UnsolvedPredicates added in v0.13.0

func (f *Filter) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the LogicalOperator interface

type GroupBy added in v0.12.0

type GroupBy struct {
	Inner         sqlparser.Expr
	WeightStrExpr sqlparser.Expr

	// This is to add the distinct function expression in grouping column for pushing down but not be to used as grouping key at VTGate level.
	// Starts with 1 so that default (0) means unassigned.
	DistinctAggrIndex 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.

type Join

type Join struct {
	LHS, RHS  LogicalOperator
	Predicate sqlparser.Expr
	LeftJoin  bool
}

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) CheckValid added in v0.12.0

func (j *Join) CheckValid() error

CheckValid implements the Operator interface

func (*Join) Compact added in v0.12.0

func (j *Join) Compact(semTable *semantics.SemTable) (LogicalOperator, error)

Compact implements the Operator interface

func (*Join) PushPredicate

func (j *Join) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the Operator interface

func (*Join) TableID

func (j *Join) TableID() semantics.TableSet

TableID implements the Operator interface

func (*Join) UnsolvedPredicates added in v0.12.0

func (j *Join) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type LogicalOperator added in v0.13.0

type LogicalOperator interface {
	Operator

	// PushPredicate pushes a predicate to the closest possible operator
	PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

	// Compact will optimise the operator tree into a smaller but equivalent version
	Compact(semTable *semantics.SemTable) (LogicalOperator, error)
	// contains filtered or unexported methods
}

func CreateOperatorFromAST added in v0.12.0

func CreateOperatorFromAST(selStmt sqlparser.SelectStatement, semTable *semantics.SemTable) (op LogicalOperator, err error)

CreateOperatorFromAST creates an operator tree that represents the input SELECT or UNION query

type Operator

type Operator interface {
	// TableID returns a TableSet of the tables contained within
	TableID() semantics.TableSet

	// UnsolvedPredicates returns any predicates that have dependencies on the given Operator and
	// on the outside of it (a parent Select expression, any other table not used by Operator, etc).
	UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr

	// CheckValid checks if we have a valid operator tree, and returns an error if something is wrong
	CheckValid() error
}

Operator forms the tree of operators, representing the declarative query provided.

type OrderBy added in v0.12.0

type OrderBy struct {
	Inner         *sqlparser.Order
	WeightStrExpr 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 PhysicalOperator added in v0.13.0

type PhysicalOperator interface {
	Operator
	IPhysical()
	// Cost is simply the number of routes in the operator tree
	Cost() int
	// Clone creates a copy of the operator that can be updated without changing the original
	Clone() PhysicalOperator
}

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) CheckValid added in v0.12.0

func (qg *QueryGraph) CheckValid() error

CheckValid implements the Operator interface

func (*QueryGraph) Compact added in v0.12.0

Compact implements the Operator interface

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) PushPredicate

func (qg *QueryGraph) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the Operator interface

func (*QueryGraph) TableID

func (qg *QueryGraph) TableID() semantics.TableSet

TableID implements the Operator interface

func (*QueryGraph) UnsolvedPredicates added in v0.12.0

func (qg *QueryGraph) UnsolvedPredicates(_ *semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type QueryProjection added in v0.12.0

type QueryProjection struct {
	// If you change the contents here, please update the toString() method
	SelectExprs        []SelectExpr
	HasAggr            bool
	Distinct           bool
	GroupByExprs       []GroupBy
	OrderExprs         []OrderBy
	CanPushDownSorting bool
	HasStar            bool
	ProjectionError    error
}

QueryProjection contains the information about the projections, group by and order by expressions used to do horizon planning.

func CreateQPFromSelect added in v0.12.0

func CreateQPFromSelect(sel *sqlparser.Select, semTable *semantics.SemTable) (*QueryProjection, error)

CreateQPFromSelect creates the QueryProjection for the input *sqlparser.Select

func CreateQPFromUnion added in v0.12.0

func CreateQPFromUnion(union *sqlparser.Union, semTable *semantics.SemTable) (*QueryProjection, error)

CreateQPFromUnion creates the QueryProjection for the input *sqlparser.Union

func (*QueryProjection) NeedsAggregation added in v0.12.0

func (qp *QueryProjection) NeedsAggregation() bool

NeedsAggregation returns true if we either have aggregate functions or grouping defined

func (*QueryProjection) NeedsDistinct added in v0.12.0

func (qp *QueryProjection) NeedsDistinct() bool

NeedsDistinct returns true if the query needs explicit distinct

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

type SelectExpr added in v0.12.0

type SelectExpr struct {
	Col  sqlparser.SelectExpr
	Aggr bool
}

SelectExpr provides whether the columns is aggregation expression or not.

func (SelectExpr) GetAliasedExpr added in v0.12.0

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.

func (SelectExpr) GetExpr added in v0.12.0

func (s SelectExpr) GetExpr() (sqlparser.Expr, error)

GetExpr returns the underlying sqlparser.Expr of our SelectExpr

type SubQuery added in v0.12.0

type SubQuery struct {
	Inner []*SubQueryInner
	Outer LogicalOperator
}

SubQuery stores the information about subquery

func (*SubQuery) CheckValid added in v0.12.0

func (s *SubQuery) CheckValid() error

CheckValid implements the Operator interface

func (*SubQuery) Compact added in v0.12.0

Compact implements the Operator interface

func (*SubQuery) PushPredicate added in v0.12.0

PushPredicate implements the Operator interface

func (*SubQuery) TableID added in v0.12.0

func (s *SubQuery) TableID() semantics.TableSet

TableID implements the Operator interface

func (*SubQuery) UnsolvedPredicates added in v0.12.0

func (s *SubQuery) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type SubQueryInner added in v0.12.0

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 LogicalOperator

	// ExtractedSubquery contains all information we need about this subquery
	ExtractedSubquery *sqlparser.ExtractedSubquery
}

SubQueryInner stores the subquery information for a select statement

type Vindex added in v0.12.0

type Vindex struct {
	OpCode engine.VindexOpcode
	Table  VindexTable
	Vindex vindexes.Vindex
	Value  sqlparser.Expr
}

Vindex stores the information about the vindex query

func (*Vindex) CheckValid added in v0.12.0

func (v *Vindex) CheckValid() error

CheckValid implements the Operator interface

func (*Vindex) Compact added in v0.12.0

func (v *Vindex) Compact(*semantics.SemTable) (LogicalOperator, error)

Compact implements the Operator interface

func (*Vindex) PushPredicate added in v0.12.0

func (v *Vindex) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) (LogicalOperator, error)

PushPredicate implements the Operator interface

func (*Vindex) TableID added in v0.12.0

func (v *Vindex) TableID() semantics.TableSet

TableID implements the Operator interface

func (*Vindex) UnsolvedPredicates added in v0.12.0

func (v *Vindex) UnsolvedPredicates(*semantics.SemTable) []sqlparser.Expr

UnsolvedPredicates implements the Operator interface

type VindexTable added in v0.12.0

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

Jump to

Keyboard shortcuts

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