forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve_indices.go
112 lines (102 loc) · 3.28 KB
/
resolve_indices.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright 2016 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package plan
import (
"github.com/pingcap/tidb/expression"
)
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Projection) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
for _, expr := range p.Exprs {
expr.ResolveIndices(p.children[0].Schema())
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Join) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
lSchema := p.children[0].Schema()
rSchema := p.children[1].Schema()
for _, fun := range p.EqualConditions {
fun.GetArgs()[0].ResolveIndices(lSchema)
fun.GetArgs()[1].ResolveIndices(rSchema)
}
for _, expr := range p.LeftConditions {
expr.ResolveIndices(lSchema)
}
for _, expr := range p.RightConditions {
expr.ResolveIndices(rSchema)
}
for _, expr := range p.OtherConditions {
expr.ResolveIndices(expression.MergeSchema(lSchema, rSchema))
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Selection) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
for _, expr := range p.Conditions {
expr.ResolveIndices(p.children[0].Schema())
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Aggregation) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
for _, aggFun := range p.AggFuncs {
for _, arg := range aggFun.GetArgs() {
arg.ResolveIndices(p.children[0].Schema())
}
}
for _, item := range p.GroupByItems {
item.ResolveIndices(p.children[0].Schema())
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Sort) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
for _, item := range p.ByItems {
item.Expr.ResolveIndices(p.children[0].Schema())
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Apply) ResolveIndicesAndCorCols() {
p.Join.ResolveIndicesAndCorCols()
for _, col := range p.corCols {
col.Column.ResolveIndices(p.children[0].Schema())
}
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Update) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
orderedList := make([]*expression.Assignment, len(p.OrderedList))
schema := p.children[0].Schema()
for _, v := range p.OrderedList {
if v == nil {
continue
}
orderedList[schema.ColumnIndex(v.Col)] = v
}
for i := 0; i < len(orderedList); i++ {
if orderedList[i] == nil {
continue
}
orderedList[i].Col.ResolveIndices(schema)
orderedList[i].Expr.ResolveIndices(schema)
}
p.OrderedList = orderedList
}
// ResolveIndicesAndCorCols implements LogicalPlan interface.
func (p *Insert) ResolveIndicesAndCorCols() {
p.baseLogicalPlan.ResolveIndicesAndCorCols()
for _, asgn := range p.OnDuplicate {
asgn.Expr.ResolveIndices(p.tableSchema)
}
}