Skip to content

Commit d728d6a

Browse files
author
James Cor
committed
revert index change
1 parent 3c760f6 commit d728d6a

File tree

8 files changed

+6
-53
lines changed

8 files changed

+6
-53
lines changed

memory/index.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ func (idx *Index) Expressions() []string {
7373
return exprs
7474
}
7575

76-
func (idx *Index) UnqualifiedExpressions() []string {
77-
exprs := make([]string, len(idx.Exprs))
78-
for i, e := range idx.Exprs {
79-
str := e.String()
80-
exprs[i] = str[strings.IndexByte(str, '.')+1:]
81-
}
82-
return exprs
83-
}
84-
8576
func (idx *Index) ExtendedExpressions() []string {
8677
var exprs []string
8778
foundCols := make(map[string]struct{})

sql/analyzer/index_analyzer_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package analyzer
1616

1717
import (
18-
"strings"
1918
"testing"
2019

2120
"github.com/stretchr/testify/require"
@@ -132,26 +131,18 @@ type dummyIdx struct {
132131

133132
var _ sql.Index = (*dummyIdx)(nil)
134133

135-
func (i dummyIdx) CanSupport(context *sql.Context, r ...sql.Range) bool {
134+
func (i *dummyIdx) CanSupport(context *sql.Context, r ...sql.Range) bool {
136135
return true
137136
}
138137

139-
func (i dummyIdx) Expressions() []string {
138+
func (i *dummyIdx) Expressions() []string {
140139
var exprs []string
141140
for _, e := range i.expr {
142141
exprs = append(exprs, e.String())
143142
}
144143
return exprs
145144
}
146145

147-
func (i dummyIdx) UnqualifiedExpressions() []string {
148-
exprs := make([]string, len(i.expr))
149-
for i, e := range i.expr {
150-
str := e.String()
151-
exprs[i] = str[strings.IndexByte(str, '.')+1:]
152-
}
153-
return exprs
154-
}
155146
func (i *dummyIdx) ID() string { return i.id }
156147
func (i *dummyIdx) Database() string { return i.database }
157148
func (i *dummyIdx) Table() string { return i.table }

sql/index.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ type Index interface {
102102
// one expression, it means the index has multiple columns indexed. If it's
103103
// just one, it means it may be an expression or a column.
104104
Expressions() []string
105-
// UnqualifiedExpressions returns the indexed expressions without the source.
106-
UnqualifiedExpressions() []string
107105
// IsUnique returns whether this index is unique
108106
IsUnique() bool
109107
// IsSpatial returns whether this index is a spatial index

sql/index_builder_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ func (i testIndex) Expressions() []string {
188188
return res
189189
}
190190

191-
func (i testIndex) UnqualifiedExpressions() []string {
192-
res := make([]string, i.numcols)
193-
for i := range res {
194-
res[i] = fmt.Sprintf("column_%d", i)
195-
}
196-
return res
197-
}
198-
199191
func (testIndex) IsUnique() bool {
200192
return false
201193
}

sql/index_registry_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package sql
1616

1717
import (
1818
"fmt"
19-
"strings"
2019
"testing"
2120

2221
"github.com/stretchr/testify/require"
@@ -445,15 +444,6 @@ func (i dummyIdx) Expressions() []string {
445444
return exprs
446445
}
447446

448-
func (i dummyIdx) UnqualifiedExpressions() []string {
449-
exprs := make([]string, len(i.expr))
450-
for i, e := range i.expr {
451-
str := e.String()
452-
exprs[i] = str[strings.IndexByte(str, '.')+1:]
453-
}
454-
return exprs
455-
}
456-
457447
func (i dummyIdx) ID() string { return i.id }
458448
func (i dummyIdx) Database() string { return i.database }
459449
func (i dummyIdx) Table() string { return i.table }

sql/memo/rel_props.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ func newRelProps(rel RelExpr) *relProps {
133133
// idxExprsColumns returns the column names used in an index's expressions.
134134
// Identifiers are ambiguous.
135135
func idxExprsColumns(idx sql.Index) []string {
136-
columns := idx.UnqualifiedExpressions()
136+
columns := idx.Expressions()
137137
for i := 0; i < len(columns); i++ {
138-
columns[i] = strings.ToLower(columns[i])
138+
columns[i] = strings.ToLower(columns[i][strings.IndexByte(columns[i], '.')+1:])
139139
}
140140
return columns
141141
}
@@ -789,7 +789,7 @@ func sortedColsForRel(rel RelExpr) sql.Schema {
789789
}
790790
case *MergeJoin:
791791
var ret sql.Schema
792-
for _, e := range r.InnerScan.Table.Index().UnqualifiedExpressions() {
792+
for _, e := range r.InnerScan.Table.Index().Expressions() {
793793
// TODO columns can have "." characters, this will miss cases
794794
ret = append(ret, &sql.Column{
795795
Name: strings.ToLower(e),

sql/memo/rel_props_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package memo
22

33
import (
44
"fmt"
5-
"strings"
65
"testing"
76

87
"github.com/stretchr/testify/require"
@@ -218,14 +217,6 @@ func (i dummyIndex) Expressions() []string {
218217
return i.cols
219218
}
220219

221-
func (i dummyIndex) UnqualifiedExpressions() []string {
222-
res := make([]string, len(i.cols))
223-
for idx, col := range i.cols {
224-
res[idx] = col[strings.IndexByte(col, '.')+1:]
225-
}
226-
return res
227-
}
228-
229220
func (dummyIndex) IsUnique() bool {
230221
return true
231222
}

sql/planbuilder/ddl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func (b *Builder) getIndexDefs(table sql.Table) sql.IndexDefs {
412412
constraint = sql.IndexConstraint_Unique
413413
}
414414
}
415-
exprs := idx.UnqualifiedExpressions()
415+
exprs := idx.Expressions()
416416
columns := make([]sql.IndexColumn, len(exprs))
417417
for i, col := range exprs {
418418
columns[i] = sql.IndexColumn{Name: col}

0 commit comments

Comments
 (0)