Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Join ¶
Join represents an join. If we have a predicate, this is an inner join. If no predicate exists, it is a cross join
func (*Join) PushPredicate ¶
PushPredicate implements the Operator interface
type LeftJoin ¶
LeftJoin represents an outerjoin.
func (*LeftJoin) PushPredicate ¶
PushPredicate implements the Operator interface
type Operator ¶
type Operator interface { // TableID returns a TableSet of the tables contained within TableID() semantics.TableSet // PushPredicate pushes a predicate to the closest possible operator PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error }
Operator forms the tree of operators, representing the declarative query provided. An operator can be:
- QueryGraph - which represents a group of tables and predicates that can be evaluated in any order while still preserving the results
- LeftJoin - A left join. These can't be evaluated in any order, so we keep them separate
- Join - A join represents inner join.
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) 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 ¶
PushPredicate implements the Operator interface
func (*QueryGraph) TableID ¶
func (qg *QueryGraph) TableID() semantics.TableSet
TableID implements the Operator interface
type QueryTable ¶
type QueryTable struct { TableID semantics.TableSet Alias *sqlparser.AliasedTableExpr Table sqlparser.TableName Predicates []sqlparser.Expr }
QueryTable is a single FROM table, including all predicates particular to this table