@@ -133,11 +133,12 @@ func newRelProps(rel RelExpr) *relProps {
133133// idxExprsColumns returns the column names used in an index's expressions.
134134// Identifiers are ambiguous.
135135func idxExprsColumns (idx sql.Index ) []string {
136- columns := idx .Expressions ()
137- for i := 0 ; i < len (columns ); i ++ {
138- columns [i ] = strings .ToLower (columns [i ][strings .IndexByte (columns [i ], '.' )+ 1 :])
136+ exprs := idx .Expressions ()
137+ for i , e := range exprs {
138+ colName := e [strings .IndexByte (e , '.' )+ 1 :]
139+ exprs [i ] = strings .ToLower (colName )
139140 }
140- return columns
141+ return exprs
141142}
142143
143144func (p * relProps ) SetStats (s sql.Statistic ) {
@@ -791,8 +792,12 @@ func sortedColsForRel(rel RelExpr) sql.Schema {
791792 var ret sql.Schema
792793 for _ , e := range r .InnerScan .Table .Index ().Expressions () {
793794 // TODO columns can have "." characters, this will miss cases
795+ idx := strings .IndexRune (e , '.' )
796+ if idx == - 1 {
797+ return nil
798+ }
794799 ret = append (ret , & sql.Column {
795- Name : strings .ToLower (e ),
800+ Name : strings .ToLower (e [ idx + 1 :] ),
796801 Source : strings .ToLower (r .InnerScan .Table .Name ()),
797802 Nullable : true },
798803 )
0 commit comments