Skip to content

Commit

Permalink
refactor: minor cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Feb 6, 2024
1 parent 3e5d494 commit db7a62c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 0 additions & 3 deletions go/vt/vtgate/planbuilder/collations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/test/vschemawrapper"
"vitess.io/vitess/go/vt/vtenv"
"vitess.io/vitess/go/vt/vtgate/engine"
Expand Down Expand Up @@ -61,8 +60,6 @@ func (tc *collationTestCase) addCollationsToSchema(vschema *vschemawrapper.VSche
for i, c := range tbl.Columns {
if c.Name.EqualString(collation.colName) {
tbl.Columns[i].CollationName = collation.collationName
} else if c.CollationName == "" && sqltypes.IsText(c.Type) {
tbl.Columns[i].CollationName = "latin1_swedish_ci"
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions go/vt/vtgate/semantics/real_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ func vindexTableToColumnInfo(tbl *vindexes.Table, collationEnv *collations.Envir
nameMap := map[string]any{}
cols := make([]ColumnInfo, 0, len(tbl.Columns))
for _, col := range tbl.Columns {
tt := col.ToEvalengineType(collationEnv)
cols = append(cols, ColumnInfo{
Name: col.Name.String(),
Type: tt,
Type: col.ToEvalengineType(collationEnv),
Invisible: col.Invisible,
})
nameMap[col.Name.String()] = nil
Expand Down
16 changes: 8 additions & 8 deletions go/vt/vtgate/vindexes/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,17 @@ import (
"strings"
"time"

"vitess.io/vitess/go/json2"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/sqlescape"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtgate/evalengine"

"vitess.io/vitess/go/json2"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/sqlparser"

querypb "vitess.io/vitess/go/vt/proto/query"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
vschemapb "vitess.io/vitess/go/vt/proto/vschema"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtgate/evalengine"
)

// TabletTypeSuffix maps the tablet type to its suffix string.
Expand Down Expand Up @@ -220,9 +218,11 @@ func (col *Column) MarshalJSON() ([]byte, error) {
}

func (col *Column) ToEvalengineType(collationEnv *collations.Environment) evalengine.Type {
collation := collations.CollationForType(col.Type, collationEnv.DefaultConnectionCharset())
var collation collations.ID
if sqltypes.IsText(col.Type) {
collation, _ = collationEnv.LookupID(col.CollationName)
} else {
collation = collations.CollationForType(col.Type, collationEnv.DefaultConnectionCharset())
}
return evalengine.NewTypeEx(col.Type, collation, col.Nullable, col.Size, col.Scale)
}
Expand Down

0 comments on commit db7a62c

Please sign in to comment.