Documentation ¶
Index ¶
- func GetProject(root PlanNode) string
- func LookupFromWhere(database, table, shardkey string, where *sqlparser.Where, ...) ([]router.Segment, error)
- type AggregatePlan
- func (p *AggregatePlan) Build() error
- func (p *AggregatePlan) Empty() bool
- func (p *AggregatePlan) GroupAggregators() []Aggregator
- func (p *AggregatePlan) JSON() string
- func (p *AggregatePlan) NormalAggregators() []Aggregator
- func (p *AggregatePlan) ReWritten() sqlparser.SelectExprs
- func (p *AggregatePlan) Type() ChildType
- type Aggregator
- type ChildPlan
- type ChildType
- type Comparison
- type Direction
- type JoinKey
- type JoinNode
- type JoinStrategy
- type LimitPlan
- type MergeNode
- type OrderBy
- type OrderByPlan
- type PlanNode
- type UnionNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProject ¶
GetProject return the project which is used in explain.
Types ¶
type AggregatePlan ¶
type AggregatePlan struct { // IsPushDown whether aggfunc can be pushed down. IsPushDown bool // contains filtered or unexported fields }
AggregatePlan represents order-by plan.
func NewAggregatePlan ¶
func NewAggregatePlan(log *xlog.Log, exprs []sqlparser.SelectExpr, tuples, groups []selectTuple, isPushDown bool) *AggregatePlan
NewAggregatePlan used to create AggregatePlan.
func (*AggregatePlan) Build ¶
func (p *AggregatePlan) Build() error
Build used to build distributed querys.
func (*AggregatePlan) Empty ¶
func (p *AggregatePlan) Empty() bool
Empty returns the aggregator number more than zero.
func (*AggregatePlan) GroupAggregators ¶
func (p *AggregatePlan) GroupAggregators() []Aggregator
GroupAggregators returns the group aggregators.
func (*AggregatePlan) NormalAggregators ¶
func (p *AggregatePlan) NormalAggregators() []Aggregator
NormalAggregators returns the aggregators.
func (*AggregatePlan) ReWritten ¶
func (p *AggregatePlan) ReWritten() sqlparser.SelectExprs
ReWritten used to re-write the SelectExprs clause.
func (*AggregatePlan) Type ¶
func (p *AggregatePlan) Type() ChildType
Type returns the type of the plan.
type Aggregator ¶
Aggregator tuple.
type Comparison ¶
type Comparison struct { // index in left and right node's fields. Left, Right int Operator string // left expr may in right node. Exchange bool }
Comparison is record the sqlparser.Comparison info.
type JoinKey ¶
type JoinKey struct { // field name. Field string // table name. Table string // index in the fields. Index int }
JoinKey is the column info in the on conditions.
type JoinNode ¶
type JoinNode struct {
// Left and Right are the nodes for the join.
Left, Right PlanNode
// join strategy.
Strategy JoinStrategy
// Cols defines which columns from left or right results used to build the return result.
// For results coming from left, the values go as -1, -2, etc. For right, they're 1, 2, etc.
// If Cols is {-1, -2, 1, 2}, it means the returned result is {Left0, Left1, Right0, Right1}.
Cols []int `json:",omitempty"`
// eg: from t1 join t2 on t1.a=t2.b, 't1.a' put in LeftKeys, 't2.a' in RightKeys.
LeftKeys, RightKeys []JoinKey
// eg: t1 join t2 on t1.a>t2.a, 't1.a>t2.a' parse into CmpFilter.
CmpFilter []Comparison
// whether is left join.
IsLeftJoin bool
// whether the right node has filters in left join.
HasRightFilter bool
// record the `otherLeftJoin.left`'s index in left.fields.
LeftTmpCols []int
// record the `rightNull`'s index in right.fields.
RightTmpCols []int
// Vars defines the list of joinVars that need to be built
// from the Left result before invoking the Right subqquery.
Vars map[string]int
// contains filtered or unexported fields
}
JoinNode cannot be pushed down.
func (*JoinNode) GetQuery ¶
func (j *JoinNode) GetQuery() []xcontext.QueryTuple
GetQuery used to get the Querys.
type JoinStrategy ¶
type JoinStrategy int
JoinStrategy is Join Strategy.
const ( // Cartesian product. Cartesian JoinStrategy = iota // SortMerge Join. SortMerge // NestLoop Join. NestLoop )
type LimitPlan ¶
LimitPlan represents order-by plan.
func NewLimitPlan ¶
NewLimitPlan used to create LimitPlan.
type MergeNode ¶
type MergeNode struct { // select ast. Sel sqlparser.SelectStatement // query and backend tuple Querys []xcontext.QueryTuple // querys with bind locations. ParsedQuerys []*sqlparser.ParsedQuery // Mode. ReqMode xcontext.RequestMode // contains filtered or unexported fields }
MergeNode can be pushed down.
func (*MergeNode) GenerateFieldQuery ¶
func (m *MergeNode) GenerateFieldQuery() *sqlparser.ParsedQuery
GenerateFieldQuery generates a query with an impossible where. This will be used on the RHS node to fetch field info if the LHS returns no result.
func (*MergeNode) GetQuery ¶
func (m *MergeNode) GetQuery() []xcontext.QueryTuple
GetQuery used to get the Querys.
type OrderByPlan ¶
type OrderByPlan struct { // The indexes mark the fields to be removed. RemovedIdxs []int OrderBys []OrderBy `json:"OrderBy(s)"` // contains filtered or unexported fields }
OrderByPlan represents order-by plan.
func NewOrderByPlan ¶
NewOrderByPlan used to create OrderByPlan.
func (*OrderByPlan) Build ¶
func (p *OrderByPlan) Build() error
Build used to build distributed querys.
func (*OrderByPlan) Type ¶
func (p *OrderByPlan) Type() ChildType
Type returns the type of the plan.
type PlanNode ¶
type PlanNode interface { Children() []ChildPlan GetQuery() []xcontext.QueryTuple Order() int // contains filtered or unexported methods }
PlanNode interface.
type UnionNode ¶
type UnionNode struct {
Left, Right PlanNode
// Union Type.
Typ string
// contains filtered or unexported fields
}
UnionNode ... eg: select a, b from t1 union select t2.a,t3.b from t2 join t3 on t2.id=t3.id;
PlanNode1 / \ / \ PlanNode2 PlanNode3
PlanNode1: UnionNode PlanNode2: MergeNode PlanNode3: JoinNode
/ \ / \ MergeNode MergeNode
PlanNode2 and PlanNode3 are two independent trees, and they are also the Left and Right of PlanNode1.
func (*UnionNode) GetQuery ¶
func (u *UnionNode) GetQuery() []xcontext.QueryTuple
GetQuery used to get the Querys.