From 4f40d2a0ebb0598c6d9c504766d9224256c5a4c2 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 2 Dec 2021 10:19:47 +0100 Subject: [PATCH] refactor: remove routeLegacy and use engine.route for both v3 and gen4 Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/cached_size.go | 74 +-- go/vt/vtgate/engine/route.go | 43 +- go/vt/vtgate/engine/route_legacy.go | 599 ------------------ go/vt/vtgate/engine/route_test.go | 48 +- go/vt/vtgate/evalengine/expressions.go | 33 + go/vt/vtgate/planbuilder/ddl.go | 2 - go/vt/vtgate/planbuilder/from.go | 16 +- .../planbuilder/querytree_transformers.go | 14 +- go/vt/vtgate/planbuilder/route.go | 14 +- go/vt/vtgate/planbuilder/route_test.go | 12 +- .../planbuilder/testdata/aggr_cases.txt | 28 +- .../planbuilder/testdata/filter_cases.txt | 530 ++++------------ .../planbuilder/testdata/from_cases.txt | 176 ++--- .../planbuilder/testdata/large_cases.txt | 12 +- .../testdata/memory_sort_cases.txt | 32 +- .../planbuilder/testdata/oltp_cases.txt | 8 +- .../testdata/postprocess_cases.txt | 168 ++--- .../planbuilder/testdata/rails_cases.txt | 36 +- .../planbuilder/testdata/select_cases.txt | 128 +--- .../testdata/systemtables_cases.txt | 8 +- .../planbuilder/testdata/tpcc_cases.txt | 184 ++---- .../planbuilder/testdata/tpch_cases.txt | 20 +- .../planbuilder/testdata/union_cases.txt | 56 +- .../testdata/unsupported_cases.txt | 4 +- .../planbuilder/testdata/wireup_cases.txt | 48 +- 25 files changed, 480 insertions(+), 1813 deletions(-) delete mode 100644 go/vt/vtgate/engine/route_legacy.go diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 388b6ec1ec5..5d9f440d238 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -666,80 +666,10 @@ func (cached *Route) CachedSize(alloc bool) int64 { if cc, ok := cached.Vindex.(cachedObject); ok { size += cc.CachedSize(true) } - // field Values []vitess.io/vitess/go/vt/vtgate/evalengine.Expr - { - size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(16)) - for _, elem := range cached.Values { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } - // field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams - { - size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(36)) - } - // field SysTableTableSchema []vitess.io/vitess/go/vt/vtgate/evalengine.Expr - { - size += hack.RuntimeAllocSize(int64(cap(cached.SysTableTableSchema)) * int64(16)) - for _, elem := range cached.SysTableTableSchema { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } - // field SysTableTableName map[string]vitess.io/vitess/go/vt/vtgate/evalengine.Expr - if cached.SysTableTableName != nil { - size += int64(48) - hmap := reflect.ValueOf(cached.SysTableTableName) - numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9))))))) - numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10)))) - size += hack.RuntimeAllocSize(int64(numOldBuckets * 272)) - if len(cached.SysTableTableName) > 0 || numBuckets > 1 { - size += hack.RuntimeAllocSize(int64(numBuckets * 272)) - } - for k, v := range cached.SysTableTableName { - size += hack.RuntimeAllocSize(int64(len(k))) - if cc, ok := v.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } - return size -} - -//go:nocheckptr -func (cached *RouteLegacy) CachedSize(alloc bool) int64 { - if cached == nil { - return int64(0) - } - size := int64(0) - if alloc { - size += int64(208) - } - // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace - size += cached.Keyspace.CachedSize(true) - // field TargetDestination vitess.io/vitess/go/vt/key.Destination - if cc, ok := cached.TargetDestination.(cachedObject); ok { + // field Value vitess.io/vitess/go/vt/vtgate/engine.RouteValue + if cc, ok := cached.Value.(cachedObject); ok { size += cc.CachedSize(true) } - // field Query string - size += hack.RuntimeAllocSize(int64(len(cached.Query))) - // field TableName string - size += hack.RuntimeAllocSize(int64(len(cached.TableName))) - // field FieldQuery string - size += hack.RuntimeAllocSize(int64(len(cached.FieldQuery))) - // field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.SingleColumn - if cc, ok := cached.Vindex.(cachedObject); ok { - size += cc.CachedSize(true) - } - // field Values []vitess.io/vitess/go/sqltypes.PlanValue - { - size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(88)) - for _, elem := range cached.Values { - size += elem.CachedSize(false) - } - } // field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams { size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(36)) diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 82088f2bdd4..dd4cb932fdb 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -77,8 +77,8 @@ type Route struct { // Vindex specifies the vindex to be used. Vindex vindexes.SingleColumn - // Values specifies the vindex values to use for routing. - Values []evalengine.Expr + // Value specifies the vindex value to use for routing. + Value RouteValue // OrderBy specifies the key order for merge sorting. This will be // set only for scatter queries that need the results to be @@ -107,6 +107,16 @@ type Route struct { noTxNeeded } +type RouteValue interface { + // ResolveValue allows for retrieval of the value we expose for public consumption + ResolveValue(bindVars map[string]*querypb.BindVariable) (sqltypes.Value, error) + + // ResolveList allows for retrieval of the value we expose for public consumption + ResolveList(bindVars map[string]*querypb.BindVariable) ([]sqltypes.Value, error) + + MarshalJSON() ([]byte, error) +} + // NewSimpleRoute creates a Route with the bare minimum of parameters. func NewSimpleRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace) *Route { return &Route{ @@ -589,14 +599,11 @@ func (route *Route) paramsAnyShard(vcursor VCursor, bindVars map[string]*querypb } func (route *Route) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := &evalengine.ExpressionEnv{ - BindVars: bindVars, - } - value, err := route.Values[0].Evaluate(env) + value, err := route.Value.ResolveValue(bindVars) if err != nil { return nil, nil, err } - rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, []sqltypes.Value{value.Value()}) + rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, []sqltypes.Value{value}) if err != nil { return nil, nil, err } @@ -608,14 +615,11 @@ func (route *Route) paramsSelectEqual(vcursor VCursor, bindVars map[string]*quer } func (route *Route) paramsSelectIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := &evalengine.ExpressionEnv{ - BindVars: bindVars, - } - value, err := route.Values[0].Evaluate(env) + value, err := route.Value.ResolveList(bindVars) if err != nil { return nil, nil, err } - rss, values, err := resolveShards(vcursor, route.Vindex, route.Keyspace, value.TupleValues()) + rss, values, err := resolveShards(vcursor, route.Vindex, route.Keyspace, value) if err != nil { return nil, nil, err } @@ -623,14 +627,11 @@ func (route *Route) paramsSelectIn(vcursor VCursor, bindVars map[string]*querypb } func (route *Route) paramsSelectMultiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := &evalengine.ExpressionEnv{ - BindVars: bindVars, - } - key, err := route.Values[0].Evaluate(env) + value, err := route.Value.ResolveList(bindVars) if err != nil { return nil, nil, err } - rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, key.TupleValues()) + rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, value) if err != nil { return nil, nil, err } @@ -805,12 +806,8 @@ func (route *Route) description() PrimitiveDescription { if route.Vindex != nil { other["Vindex"] = route.Vindex.String() } - if len(route.Values) > 0 { - var values []string - for _, value := range route.Values { - values = append(values, evalengine.FormatExpr(value)) - } - other["Values"] = values + if route.Value != nil { + other["Values"] = route.Value } if len(route.SysTableTableSchema) != 0 { sysTabSchema := "[" diff --git a/go/vt/vtgate/engine/route_legacy.go b/go/vt/vtgate/engine/route_legacy.go deleted file mode 100644 index 5a51ffd9925..00000000000 --- a/go/vt/vtgate/engine/route_legacy.go +++ /dev/null @@ -1,599 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package engine - -import ( - "fmt" - "sort" - "strings" - "time" - - "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/sqlparser" - - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" - "vitess.io/vitess/go/vt/vtgate/evalengine" - - "vitess.io/vitess/go/mysql" - "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" - "vitess.io/vitess/go/vt/srvtopo" - "vitess.io/vitess/go/vt/vterrors" - "vitess.io/vitess/go/vt/vtgate/vindexes" - - querypb "vitess.io/vitess/go/vt/proto/query" - topodatapb "vitess.io/vitess/go/vt/proto/topodata" -) - -var _ Primitive = (*RouteLegacy)(nil) - -// RouteLegacy represents the instructions to route a read query to -// one or many vttablets. -type RouteLegacy struct { - // the fields are described in the RouteOpcode values comments. - // Opcode is the execution opcode. - Opcode RouteOpcode - - // Keyspace specifies the keyspace to send the query to. - Keyspace *vindexes.Keyspace - - // TargetDestination specifies an explicit target destination to send the query to. - // This bypases the core of the v3 engine. - TargetDestination key.Destination - - // TargetTabletType specifies an explicit target destination tablet type - // this is only used in conjunction with TargetDestination - TargetTabletType topodatapb.TabletType - - // Query specifies the query to be executed. - Query string - - // TableName specifies the table to send the query to. - TableName string - - // FieldQuery specifies the query to be executed for a GetFieldInfo request. - FieldQuery string - - // Vindex specifies the vindex to be used. - Vindex vindexes.SingleColumn - // Values specifies the vindex values to use for routing. - Values []sqltypes.PlanValue - - // OrderBy specifies the key order for merge sorting. This will be - // set only for scatter queries that need the results to be - // merge-sorted. - OrderBy []OrderByParams - - // TruncateColumnCount specifies the number of columns to return - // in the final result. Rest of the columns are truncated - // from the result received. If 0, no truncation happens. - TruncateColumnCount int - - // QueryTimeout contains the optional timeout (in milliseconds) to apply to this query - QueryTimeout int - - // ScatterErrorsAsWarnings is true if results should be returned even if some shards have an error - ScatterErrorsAsWarnings bool - - // The following two fields are used when routing information_schema queries - SysTableTableSchema []evalengine.Expr - SysTableTableName map[string]evalengine.Expr - - // Route does not take inputs - noInputs - - // Route does not need transaction handling - noTxNeeded -} - -// NewSimpleRouteLegacy creates a RouteLegacy with the bare minimum of parameters. -func NewSimpleRouteLegacy(opcode RouteOpcode, keyspace *vindexes.Keyspace) *RouteLegacy { - return &RouteLegacy{ - Opcode: opcode, - Keyspace: keyspace, - } -} - -// NewRouteRouteLegacy creates a RouteLegacy. -func NewRouteRouteLegacy(opcode RouteOpcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *RouteLegacy { - return &RouteLegacy{ - Opcode: opcode, - Keyspace: keyspace, - Query: query, - FieldQuery: fieldQuery, - } -} - -// RouteType returns a description of the query routing type used by the primitive -func (route *RouteLegacy) RouteType() string { - return route.Opcode.String() -} - -// GetKeyspaceName specifies the Keyspace that this primitive routes to. -func (route *RouteLegacy) GetKeyspaceName() string { - return route.Keyspace.Name -} - -// GetTableName specifies the table that this primitive routes to. -func (route *RouteLegacy) GetTableName() string { - return route.TableName -} - -// SetTruncateColumnCount sets the truncate column count. -func (route *RouteLegacy) SetTruncateColumnCount(count int) { - route.TruncateColumnCount = count -} - -// TryExecute performs a non-streaming exec. -func (route *RouteLegacy) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { - if route.QueryTimeout != 0 { - cancel := vcursor.SetContextTimeout(time.Duration(route.QueryTimeout) * time.Millisecond) - defer cancel() - } - qr, err := route.executeInternal(vcursor, bindVars, wantfields) - if err != nil { - return nil, err - } - return qr.Truncate(route.TruncateColumnCount), nil -} - -func (route *RouteLegacy) executeInternal(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { - var rss []*srvtopo.ResolvedShard - var bvs []map[string]*querypb.BindVariable - var err error - switch route.Opcode { - case SelectDBA: - rss, bvs, err = route.paramsSystemQuery(vcursor, bindVars) - case SelectUnsharded, SelectNext, SelectReference: - rss, bvs, err = route.paramsAnyShard(vcursor, bindVars) - case SelectScatter: - rss, bvs, err = route.paramsAllShards(vcursor, bindVars) - case SelectEqual, SelectEqualUnique: - rss, bvs, err = route.paramsSelectEqual(vcursor, bindVars) - case SelectIN: - rss, bvs, err = route.paramsSelectIn(vcursor, bindVars) - case SelectMultiEqual: - rss, bvs, err = route.paramsSelectMultiEqual(vcursor, bindVars) - case SelectNone: - rss, bvs, err = nil, nil, nil - default: - // Unreachable. - return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported query route: %v", route) - } - if err != nil { - return nil, err - } - - // No route. - if len(rss) == 0 { - if wantfields { - return route.GetFields(vcursor, bindVars) - } - return &sqltypes.Result{}, nil - } - - queries := getQueries(route.Query, bvs) - result, errs := vcursor.ExecuteMultiShard(rss, queries, false /* rollbackOnError */, false /* autocommit */) - - if errs != nil { - errs = filterOutNilErrors(errs) - if !route.ScatterErrorsAsWarnings || len(errs) == len(rss) { - return nil, vterrors.Aggregate(errs) - } - - partialSuccessScatterQueries.Add(1) - - for _, err := range errs { - serr := mysql.NewSQLErrorFromError(err).(*mysql.SQLError) - vcursor.Session().RecordWarning(&querypb.QueryWarning{Code: uint32(serr.Num), Message: err.Error()}) - } - } - - if len(route.OrderBy) == 0 { - return result, nil - } - - return route.sort(result) -} - -// TryStreamExecute performs a streaming exec. -func (route *RouteLegacy) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { - var rss []*srvtopo.ResolvedShard - var bvs []map[string]*querypb.BindVariable - var err error - if route.QueryTimeout != 0 { - cancel := vcursor.SetContextTimeout(time.Duration(route.QueryTimeout) * time.Millisecond) - defer cancel() - } - switch route.Opcode { - case SelectDBA: - rss, bvs, err = route.paramsSystemQuery(vcursor, bindVars) - case SelectUnsharded, SelectNext, SelectReference: - rss, bvs, err = route.paramsAnyShard(vcursor, bindVars) - case SelectScatter: - rss, bvs, err = route.paramsAllShards(vcursor, bindVars) - case SelectEqual, SelectEqualUnique: - rss, bvs, err = route.paramsSelectEqual(vcursor, bindVars) - case SelectIN: - rss, bvs, err = route.paramsSelectIn(vcursor, bindVars) - case SelectMultiEqual: - rss, bvs, err = route.paramsSelectMultiEqual(vcursor, bindVars) - case SelectNone: - rss, bvs, err = nil, nil, nil - default: - return fmt.Errorf("query %q cannot be used for streaming", route.Query) - } - if err != nil { - return err - } - - // No route. - if len(rss) == 0 { - if wantfields { - r, err := route.GetFields(vcursor, bindVars) - if err != nil { - return err - } - return callback(r) - } - return nil - } - - if len(route.OrderBy) == 0 { - errs := vcursor.StreamExecuteMulti(route.Query, rss, bvs, false /* rollbackOnError */, false /* autocommit */, func(qr *sqltypes.Result) error { - return callback(qr.Truncate(route.TruncateColumnCount)) - }) - if len(errs) > 0 { - if !route.ScatterErrorsAsWarnings || len(errs) == len(rss) { - return vterrors.Aggregate(errs) - } - partialSuccessScatterQueries.Add(1) - for _, err := range errs { - sErr := mysql.NewSQLErrorFromError(err).(*mysql.SQLError) - vcursor.Session().RecordWarning(&querypb.QueryWarning{Code: uint32(sErr.Num), Message: err.Error()}) - } - } - return nil - } - - // There is an order by. We have to merge-sort. - return route.mergeSort(vcursor, bindVars, wantfields, callback, rss, bvs) -} - -func (route *RouteLegacy) mergeSort(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error, rss []*srvtopo.ResolvedShard, bvs []map[string]*querypb.BindVariable) error { - prims := make([]StreamExecutor, 0, len(rss)) - for i, rs := range rss { - prims = append(prims, &shardRoute{ - query: route.Query, - rs: rs, - bv: bvs[i], - }) - } - ms := MergeSort{ - Primitives: prims, - OrderBy: route.OrderBy, - ScatterErrorsAsWarnings: route.ScatterErrorsAsWarnings, - } - return vcursor.StreamExecutePrimitive(&ms, bindVars, wantfields, func(qr *sqltypes.Result) error { - return callback(qr.Truncate(route.TruncateColumnCount)) - }) -} - -// GetFields fetches the field info. -func (route *RouteLegacy) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) - if err != nil { - return nil, err - } - if len(rss) != 1 { - // This code is unreachable. It's just a sanity check. - return nil, fmt.Errorf("no shards for keyspace: %s", route.Keyspace.Name) - } - qr, err := execShard(vcursor, route.FieldQuery, bindVars, rss[0], false /* rollbackOnError */, false /* canAutocommit */) - if err != nil { - return nil, err - } - return qr.Truncate(route.TruncateColumnCount), nil -} - -func (route *RouteLegacy) paramsAllShards(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *RouteLegacy) paramsSystemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - destinations, err := route.routeInfoSchemaQuery(vcursor, bindVars) - if err != nil { - return nil, nil, err - } - - return destinations, []map[string]*querypb.BindVariable{bindVars}, nil -} - -func (route *RouteLegacy) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, error) { - defaultRoute := func() ([]*srvtopo.ResolvedShard, error) { - ks := route.Keyspace.Name - destinations, _, err := vcursor.ResolveDestinations(ks, nil, []key.Destination{key.DestinationAnyShard{}}) - return destinations, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", ks) - } - - if len(route.SysTableTableName) == 0 && len(route.SysTableTableSchema) == 0 { - return defaultRoute() - } - - env := &evalengine.ExpressionEnv{ - BindVars: bindVars, - Row: []sqltypes.Value{}, - } - - var specifiedKS string - for _, tableSchema := range route.SysTableTableSchema { - result, err := tableSchema.Evaluate(env) - if err != nil { - return nil, err - } - ks := result.Value().ToString() - if specifiedKS == "" { - specifiedKS = ks - } - if specifiedKS != ks { - return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "specifying two different database in the query is not supported") - } - } - if specifiedKS != "" { - bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) - } - - tableNames := map[string]string{} - for tblBvName, sysTableName := range route.SysTableTableName { - val, err := sysTableName.Evaluate(env) - if err != nil { - return nil, err - } - tabName := val.Value().ToString() - tableNames[tblBvName] = tabName - bindVars[tblBvName] = sqltypes.StringBindVariable(tabName) - } - - // if the table_schema is system schema, route to default keyspace. - if sqlparser.SystemSchema(specifiedKS) { - return defaultRoute() - } - - // the use has specified a table_name - let's check if it's a routed table - if len(tableNames) > 0 { - rss, err := route.paramsRoutedTable(vcursor, bindVars, specifiedKS, tableNames) - if err != nil { - // Only if keyspace is not found in vschema, we try with default keyspace. - // As the in the table_schema predicates for a keyspace 'ks' it can contain 'vt_ks'. - if vterrors.ErrState(err) == vterrors.BadDb { - return defaultRoute() - } - return nil, err - } - if rss != nil { - return rss, nil - } - } - - // it was not a routed table, and we dont have a schema name to look up. give up - if specifiedKS == "" { - return defaultRoute() - } - - // we only have table_schema to work with - destinations, _, err := vcursor.ResolveDestinations(specifiedKS, nil, []key.Destination{key.DestinationAnyShard{}}) - if err != nil { - log.Errorf("failed to route information_schema query to keyspace [%s]", specifiedKS) - bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) - return defaultRoute() - } - setReplaceSchemaName(bindVars) - return destinations, nil -} - -func (route *RouteLegacy) paramsRoutedTable(vcursor VCursor, bindVars map[string]*querypb.BindVariable, tableSchema string, tableNames map[string]string) ([]*srvtopo.ResolvedShard, error) { - var routedKs *vindexes.Keyspace - for tblBvName, tableName := range tableNames { - tbl := sqlparser.TableName{ - Name: sqlparser.NewTableIdent(tableName), - Qualifier: sqlparser.NewTableIdent(tableSchema), - } - routedTable, err := vcursor.FindRoutedTable(tbl) - if err != nil { - return nil, err - } - - if routedTable != nil { - // if we were able to find information about this table, let's use it - - // check if the query is send to single keyspace. - if routedKs == nil { - routedKs = routedTable.Keyspace - } - if routedKs.Name != routedTable.Keyspace.Name { - return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot send the query to multiple keyspace due to different table_name: %s, %s", routedKs.Name, routedTable.Keyspace.Name) - } - - shards, _, err := vcursor.ResolveDestinations(routedTable.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) - bindVars[tblBvName] = sqltypes.StringBindVariable(routedTable.Name.String()) - if tableSchema != "" { - setReplaceSchemaName(bindVars) - } - return shards, err - } - // no routed table info found. we'll return nil and check on the outside if we can find the table_schema - bindVars[tblBvName] = sqltypes.StringBindVariable(tableName) - } - return nil, nil -} - -func (route *RouteLegacy) paramsAnyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *RouteLegacy) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - key, err := route.Values[0].ResolveValue(bindVars) - if err != nil { - return nil, nil, err - } - rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, []sqltypes.Value{key}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *RouteLegacy) paramsSelectIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - keys, err := route.Values[0].ResolveList(bindVars) - if err != nil { - return nil, nil, err - } - rss, values, err := resolveShards(vcursor, route.Vindex, route.Keyspace, keys) - if err != nil { - return nil, nil, err - } - return rss, shardVars(bindVars, values), nil -} - -func (route *RouteLegacy) paramsSelectMultiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - keys, err := route.Values[0].ResolveList(bindVars) - if err != nil { - return nil, nil, err - } - rss, _, err := resolveShards(vcursor, route.Vindex, route.Keyspace, keys) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *RouteLegacy) sort(in *sqltypes.Result) (*sqltypes.Result, error) { - var err error - // Since Result is immutable, we make a copy. - // The copy can be shallow because we won't be changing - // the contents of any row. - out := &sqltypes.Result{ - Fields: in.Fields, - Rows: in.Rows, - RowsAffected: in.RowsAffected, - InsertID: in.InsertID, - } - - comparers := extractSlices(route.OrderBy) - - sort.Slice(out.Rows, func(i, j int) bool { - var cmp int - if err != nil { - return true - } - // If there are any errors below, the function sets - // the external err and returns true. Once err is set, - // all subsequent calls return true. This will make - // Slice think that all elements are in the correct - // order and return more quickly. - for _, c := range comparers { - cmp, err = c.compare(out.Rows[i], out.Rows[j]) - if err != nil { - return true - } - if cmp == 0 { - continue - } - return cmp < 0 - } - return true - }) - - return out, err -} - -func (route *RouteLegacy) description() PrimitiveDescription { - other := map[string]interface{}{ - "Query": route.Query, - "Table": route.TableName, - "FieldQuery": route.FieldQuery, - } - if route.Vindex != nil { - other["Vindex"] = route.Vindex.String() - } - if len(route.Values) > 0 { - other["Values"] = route.Values - } - if len(route.SysTableTableSchema) != 0 { - sysTabSchema := "[" - for idx, tableSchema := range route.SysTableTableSchema { - if idx != 0 { - sysTabSchema += ", " - } - sysTabSchema += evalengine.FormatExpr(tableSchema) - } - sysTabSchema += "]" - other["SysTableTableSchema"] = sysTabSchema - } - if len(route.SysTableTableName) != 0 { - var sysTableName []string - for k, v := range route.SysTableTableName { - sysTableName = append(sysTableName, k+":"+evalengine.FormatExpr(v)) - } - sort.Strings(sysTableName) - other["SysTableTableName"] = "[" + strings.Join(sysTableName, ", ") + "]" - } - orderBy := GenericJoin(route.OrderBy, orderByToString) - if orderBy != "" { - other["OrderBy"] = orderBy - } - if route.TruncateColumnCount > 0 { - other["ResultColumns"] = route.TruncateColumnCount - } - if route.ScatterErrorsAsWarnings { - other["ScatterErrorsAsWarnings"] = true - } - if route.QueryTimeout > 0 { - other["QueryTimeout"] = route.QueryTimeout - } - return PrimitiveDescription{ - OperatorType: "Route", - Variant: routeName[route.Opcode], - Keyspace: route.Keyspace, - TargetDestination: route.TargetDestination, - Other: other, - } -} diff --git a/go/vt/vtgate/engine/route_test.go b/go/vt/vtgate/engine/route_test.go index d95f9e1b8ac..fce887ca8a3 100644 --- a/go/vt/vtgate/engine/route_test.go +++ b/go/vt/vtgate/engine/route_test.go @@ -235,8 +235,9 @@ func TestSelectEqualUnique(t *testing.T) { ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{evalengine.NewLiteralInt(1)} - + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralInt(1), + } vc := &loggingVCursor{ shards: []string{"-20", "20-"}, results: []*sqltypes.Result{defaultSelectResult}, @@ -271,7 +272,7 @@ func TestSelectNone(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = nil + sel.Value = nil vc := &loggingVCursor{ shards: []string{"-20", "20-"}, @@ -306,8 +307,9 @@ func TestSelectEqualUniqueScatter(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{evalengine.NewLiteralInt(1)} - + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralInt(1), + } vc := &loggingVCursor{ shards: []string{"-20", "20-"}, shardForKsid: []string{"-20", "20-"}, @@ -347,8 +349,9 @@ func TestSelectEqual(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{evalengine.NewLiteralInt(1)} - + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralInt(1), + } vc := &loggingVCursor{ shards: []string{"-20", "20-"}, results: []*sqltypes.Result{ @@ -399,7 +402,9 @@ func TestSelectEqualNoRoute(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{evalengine.NewLiteralInt(1)} + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralInt(1), + } vc := &loggingVCursor{shards: []string{"-20", "20-"}} result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) @@ -432,8 +437,8 @@ func TestSelectINUnique(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{ - evalengine.TupleExpr{ + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.TupleExpr{ evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2), evalengine.NewLiteralInt(4), @@ -481,8 +486,8 @@ func TestSelectINNonUnique(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{ - evalengine.TupleExpr{ + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.TupleExpr{ evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2), evalengine.NewLiteralInt(4), @@ -544,8 +549,8 @@ func TestSelectMultiEqual(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{ - evalengine.TupleExpr{ + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.TupleExpr{ evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2), evalengine.NewLiteralInt(4), @@ -595,10 +600,9 @@ func TestSelectLike(t *testing.T) { ) sel.Vindex = vindex - sel.Values = []evalengine.Expr{ - evalengine.NewLiteralString([]byte("a%"), collations.TypedCollation{}), + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralString([]byte("a%"), collations.TypedCollation{}), } - // md5("a") = 0cc175b9c0f1b6a831c399e269772661 // keyspace id prefix for "a" is 0x0c vc.shardForKsid = []string{"-0c80", "0c80-0d"} @@ -626,8 +630,8 @@ func TestSelectLike(t *testing.T) { vc.Rewind() - sel.Values = []evalengine.Expr{ - evalengine.NewLiteralString([]byte("ab%"), collations.TypedCollation{}), + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralString([]byte("ab%"), collations.TypedCollation{}), } // md5("b") = 92eb5ffee6ae2fec3ad71c777531578f // keyspace id prefix for "ab" is 0x0c92 @@ -768,7 +772,9 @@ func TestRouteGetFields(t *testing.T) { "dummy_select_field", ) sel.Vindex = vindex.(vindexes.SingleColumn) - sel.Values = []evalengine.Expr{evalengine.NewLiteralInt(1)} + sel.Value = &evalengine.RouteValue{ + Expr: evalengine.NewLiteralInt(1), + } vc := &loggingVCursor{shards: []string{"-20", "20-"}} result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, true) @@ -1199,7 +1205,7 @@ func TestRouteStreamTruncate(t *testing.T) { expectResult(t, "sel.Execute", result, wantResult) } -func XTestRouteStreamSortTruncate(t *testing.T) { +func TestRouteStreamSortTruncate(t *testing.T) { sel := NewRoute( SelectUnsharded, &vindexes.Keyspace{ diff --git a/go/vt/vtgate/evalengine/expressions.go b/go/vt/vtgate/evalengine/expressions.go index 23928cbdde7..eb7f98e8da8 100644 --- a/go/vt/vtgate/evalengine/expressions.go +++ b/go/vt/vtgate/evalengine/expressions.go @@ -17,6 +17,7 @@ limitations under the License. package evalengine import ( + "encoding/json" "fmt" "math" "strconv" @@ -56,6 +57,10 @@ type ( format(buf *strings.Builder, wrap bool) } + RouteValue struct { + Expr Expr + } + Literal struct { Val EvalResult } @@ -74,6 +79,34 @@ type ( } ) +// ResolveValue allows for retrieval of the value we expose for public consumption +func (rv *RouteValue) ResolveValue(bindVars map[string]*querypb.BindVariable) (sqltypes.Value, error) { + env := &ExpressionEnv{ + BindVars: bindVars, + } + evalResul, err := rv.Expr.Evaluate(env) + if err != nil { + return sqltypes.Value{}, err + } + return evalResul.Value(), nil +} + +// ResolveList allows for retrieval of the value we expose for public consumption +func (rv *RouteValue) ResolveList(bindVars map[string]*querypb.BindVariable) ([]sqltypes.Value, error) { + env := &ExpressionEnv{ + BindVars: bindVars, + } + evalResul, err := rv.Expr.Evaluate(env) + if err != nil { + return nil, err + } + return evalResul.TupleValues(), nil +} + +func (rv *RouteValue) MarshalJSON() ([]byte, error) { + return json.Marshal(FormatExpr(rv.Expr)) +} + func (t TupleExpr) Collation() collations.TypedCollation { // a Tuple does not have a collation, but an individual collation for every element of the tuple return collations.TypedCollation{} diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go index 6a33dd3b045..210d4562426 100644 --- a/go/vt/vtgate/planbuilder/ddl.go +++ b/go/vt/vtgate/planbuilder/ddl.go @@ -367,8 +367,6 @@ func tryToGetRoutePlan(selectPlan engine.Primitive) (valid bool, keyspaceName st switch plan := selectPlan.(type) { case *engine.Route: return true, plan.Keyspace.Name, plan.Opcode - case *engine.RouteLegacy: - return true, plan.Keyspace.Name, plan.Opcode case engine.Gen4Comparer: return tryToGetRoutePlan(plan.GetGen4Primitive()) default: diff --git a/go/vt/vtgate/planbuilder/from.go b/go/vt/vtgate/planbuilder/from.go index e66be4fbb51..bdcf02eae5d 100644 --- a/go/vt/vtgate/planbuilder/from.go +++ b/go/vt/vtgate/planbuilder/from.go @@ -189,7 +189,7 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl return err } rb, st := newRouteLegacy(sel) - rb.eroute = engine.NewSimpleRouteLegacy(engine.SelectDBA, ks) + rb.eroute = engine.NewSimpleRoute(engine.SelectDBA, ks) rb.eroute.TableName = sqlparser.String(tableName) pb.plan, pb.st = rb, st // Add the table to symtab @@ -243,26 +243,26 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl rb.substitutions = []*tableSubstitution{sub} } - var eroute *engine.RouteLegacy + var eroute *engine.Route switch { case vschemaTable.Type == vindexes.TypeSequence: - eroute = engine.NewSimpleRouteLegacy(engine.SelectNext, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.SelectNext, vschemaTable.Keyspace) case vschemaTable.Type == vindexes.TypeReference: - eroute = engine.NewSimpleRouteLegacy(engine.SelectReference, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.SelectReference, vschemaTable.Keyspace) case !vschemaTable.Keyspace.Sharded: - eroute = engine.NewSimpleRouteLegacy(engine.SelectUnsharded, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.SelectUnsharded, vschemaTable.Keyspace) case vschemaTable.Pinned == nil: - eroute = engine.NewSimpleRouteLegacy(engine.SelectScatter, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.SelectScatter, vschemaTable.Keyspace) eroute.TargetDestination = destTarget eroute.TargetTabletType = destTableType default: // Pinned tables have their keyspace ids already assigned. // Use the Binary vindex, which is the identity function // for keyspace id. - eroute = engine.NewSimpleRouteLegacy(engine.SelectEqualUnique, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.SelectEqualUnique, vschemaTable.Keyspace) vindex, _ = vindexes.NewBinary("binary", nil) eroute.Vindex, _ = vindex.(vindexes.SingleColumn) - eroute.Values = []sqltypes.PlanValue{{Value: sqltypes.MakeTrusted(sqltypes.VarBinary, vschemaTable.Pinned)}} + eroute.Value = sqltypes.PlanValue{Value: sqltypes.MakeTrusted(sqltypes.VarBinary, vschemaTable.Pinned)} } eroute.TableName = sqlparser.String(vschemaTable.Name) rb.eroute = eroute diff --git a/go/vt/vtgate/planbuilder/querytree_transformers.go b/go/vt/vtgate/planbuilder/querytree_transformers.go index 16bbf8c9bfe..42be2423393 100644 --- a/go/vt/vtgate/planbuilder/querytree_transformers.go +++ b/go/vt/vtgate/planbuilder/querytree_transformers.go @@ -428,10 +428,18 @@ func transformRoutePlan(ctx *planningContext, n *routeTree) (*routeGen4, error) } var singleColumn vindexes.SingleColumn - var values []evalengine.Expr + var value engine.RouteValue if n.selectedVindex() != nil { singleColumn = n.selected.foundVindex.(vindexes.SingleColumn) - values = n.selected.values + if len(n.selected.values) == 1 { + value = &evalengine.RouteValue{Expr: n.selected.values[0]} + } else { + tuple := evalengine.TupleExpr{} + for _, value := range n.selected.values { + tuple = append(tuple, value) + } + value = &evalengine.RouteValue{Expr: tuple} + } } var expressions sqlparser.SelectExprs @@ -468,7 +476,7 @@ func transformRoutePlan(ctx *planningContext, n *routeTree) (*routeGen4, error) TableName: strings.Join(tableNames, ", "), Keyspace: n.keyspace, Vindex: singleColumn, - Values: values, + Value: value, SysTableTableName: n.SysTableTableName, SysTableTableSchema: n.SysTableTableSchema, }, diff --git a/go/vt/vtgate/planbuilder/route.go b/go/vt/vtgate/planbuilder/route.go index 687389e3224..1b147042cef 100644 --- a/go/vt/vtgate/planbuilder/route.go +++ b/go/vt/vtgate/planbuilder/route.go @@ -63,7 +63,7 @@ type route struct { condition sqlparser.Expr // eroute is the primitive being built. - eroute *engine.RouteLegacy + eroute *engine.Route // tables keeps track of which tables this route is covering tables semantics.TableSet @@ -145,7 +145,7 @@ func (rb *route) WireupGen4(semTable *semantics.SemTable) error { return nil } -// Solves implements the logicalPlan interface +// ContainsTables implements the logicalPlan interface func (rb *route) ContainsTables() semantics.TableSet { return rb.tables } @@ -153,7 +153,7 @@ func (rb *route) ContainsTables() semantics.TableSet { // Wireup implements the logicalPlan interface func (rb *route) Wireup(plan logicalPlan, jt *jointab) error { // Precaution: update ERoute.Values only if it's not set already. - if rb.eroute.Values == nil { + if rb.eroute.Value == nil { // Resolve values stored in the logical plan. switch vals := rb.condition.(type) { case *sqlparser.ComparisonExpr: @@ -161,7 +161,7 @@ func (rb *route) Wireup(plan logicalPlan, jt *jointab) error { if err != nil { return err } - rb.eroute.Values = []sqltypes.PlanValue{pv} + rb.eroute.Value = pv vals.Right = sqlparser.ListArg(engine.ListVarName) case nil: // no-op. @@ -170,7 +170,7 @@ func (rb *route) Wireup(plan logicalPlan, jt *jointab) error { if err != nil { return err } - rb.eroute.Values = []sqltypes.PlanValue{pv} + rb.eroute.Value = pv } } @@ -179,11 +179,11 @@ func (rb *route) Wireup(plan logicalPlan, jt *jointab) error { switch node := node.(type) { case *sqlparser.Select: if len(node.SelectExprs) == 0 { - node.SelectExprs = sqlparser.SelectExprs([]sqlparser.SelectExpr{ + node.SelectExprs = []sqlparser.SelectExpr{ &sqlparser.AliasedExpr{ Expr: sqlparser.NewIntLiteral("1"), }, - }) + } } case *sqlparser.ComparisonExpr: if node.Operator == sqlparser.EqualOp { diff --git a/go/vt/vtgate/planbuilder/route_test.go b/go/vt/vtgate/planbuilder/route_test.go index 48dd2a21eec..0e0efae42f2 100644 --- a/go/vt/vtgate/planbuilder/route_test.go +++ b/go/vt/vtgate/planbuilder/route_test.go @@ -71,8 +71,8 @@ func TestJoinCanMerge(t *testing.T) { rRoute := &route{ condition: &sqlparser.ColName{}, } - lRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(left), ks) - rRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(right), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) assert.Equal(t, val, lRoute.JoinCanMerge(pb, rRoute, nil, nil), fmt.Sprintf("%v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) }) } @@ -100,9 +100,9 @@ func TestSubqueryCanMerge(t *testing.T) { } rRoute := &route{} for left, vals := range testcases { - lRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(left), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) for right, val := range vals { - rRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(right), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) assert.Equal(t, val, lRoute.SubqueryCanMerge(pb, rRoute), fmt.Sprintf("%v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) } } @@ -125,9 +125,9 @@ func TestUnionCanMerge(t *testing.T) { lRoute := &route{} rRoute := &route{} for left, vals := range testcases { - lRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(left), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) for right, val := range vals { - rRoute.eroute = engine.NewSimpleRouteLegacy(engine.RouteOpcode(right), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) assert.Equal(t, val, lRoute.unionCanMerge(rRoute, false), fmt.Sprintf("can't create a single route from these two inputs %v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) } } diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt index 1bf36ef4c1b..bba259a3cec 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt @@ -34,9 +34,7 @@ Gen4 plan same as above "FieldQuery": "select count(*), col from `user` where 1 != 1", "Query": "select count(*), col from `user` where id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -53,9 +51,7 @@ Gen4 plan same as above "FieldQuery": "select count(*), col from `user` where 1 != 1", "Query": "select count(*), col from `user` where id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -830,9 +826,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "FieldQuery": "select id, count(*) as c from `user` where 1 != 1 group by id", "Query": "select id, count(*) as c from `user` group by id having id = 1 and c = 10", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -849,9 +843,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "FieldQuery": "select id, count(*) as c from `user` where 1 != 1 group by id", "Query": "select id, count(*) as c from `user` where id = 1 group by id having c = 10", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1983,9 +1975,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a from `user` where 1 != 1 group by a collate utf8_general_ci", "Query": "select `user`.col1 as a from `user` where `user`.id = 5 group by a collate utf8_general_ci", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2002,9 +1992,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a from `user` where 1 != 1 group by a collate utf8_general_ci", "Query": "select `user`.col1 as a from `user` where `user`.id = 5 group by a collate utf8_general_ci", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2758,9 +2746,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_id = 3 and user_id \u003c :user_id", "Table": "user_extra", - "Values": [ - "INT64(3)" - ], + "Values": "INT64(3)", "Vindex": "user_index" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt index b465931fc16..9f5c179263d 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt @@ -51,9 +51,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -70,9 +68,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -107,9 +103,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = 5 + 5", "Table": "`user`", - "Values": [ - "INT64(10)" - ], + "Values": "INT64(10)", "Vindex": "user_index" } } @@ -129,9 +123,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id = 5 and user_id = 4", "Table": "music", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" } } @@ -148,9 +140,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id = 5 and user_id = 4", "Table": "music", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" } } @@ -170,9 +160,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where costly = 'aa' and `name` = 'bb'", "Table": "`user`", - "Values": [ - "bb" - ], + "Values": "bb", "Vindex": "name_user_map" } } @@ -189,9 +177,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where costly = 'aa' and `name` = 'bb'", "Table": "`user`", - "Values": [ - "VARBINARY(\"bb\")" - ], + "Values": "VARBINARY(\"bb\")", "Vindex": "name_user_map" } } @@ -212,10 +198,8 @@ Gen4 plan same as above "Query": "select id from `user` where costly in ('aa', 'bb') and `name` in ::__vals", "Table": "`user`", "Values": [ - [ - "aa", - "bb" - ] + "aa", + "bb" ], "Vindex": "name_user_map" } @@ -233,9 +217,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where costly in ('aa', 'bb') and `name` in ::__vals", "Table": "`user`", - "Values": [ - "(VARBINARY(\"aa\"), VARBINARY(\"bb\"))" - ], + "Values": "(VARBINARY(\"aa\"), VARBINARY(\"bb\"))", "Vindex": "name_user_map" } } @@ -256,10 +238,8 @@ Gen4 plan same as above "Query": "select id from `user` where (`name`, col) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "aa", - "cc" - ] + "aa", + "cc" ], "Vindex": "name_user_map" } @@ -277,9 +257,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (`name`, col) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"aa\"), VARBINARY(\"cc\"))" - ], + "Values": "(VARBINARY(\"aa\"), VARBINARY(\"cc\"))", "Vindex": "name_user_map" } } @@ -300,10 +278,8 @@ Gen4 plan same as above "Query": "select id from `user` where (col, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "bb", - "dd" - ] + "bb", + "dd" ], "Vindex": "name_user_map" } @@ -321,9 +297,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (col, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))" - ], + "Values": "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))", "Vindex": "name_user_map" } } @@ -344,10 +318,8 @@ Gen4 plan same as above "Query": "select id from `user` where (costly, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "bb", - "dd" - ] + "bb", + "dd" ], "Vindex": "name_user_map" } @@ -365,9 +337,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (costly, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))" - ], + "Values": "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))", "Vindex": "name_user_map" } } @@ -388,10 +358,8 @@ Gen4 plan same as above "Query": "select id from `user` where (`name`, costly) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "aa", - "cc" - ] + "aa", + "cc" ], "Vindex": "name_user_map" } @@ -409,9 +377,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (`name`, costly) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"aa\"), VARBINARY(\"cc\"))" - ], + "Values": "(VARBINARY(\"aa\"), VARBINARY(\"cc\"))", "Vindex": "name_user_map" } } @@ -432,9 +398,7 @@ Gen4 plan same as above "Query": "select id from `user` where (col, costly) in (('aa', 'bb')) and (col, `name`) in (('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "dd" - ] + "dd" ], "Vindex": "name_user_map" } @@ -452,9 +416,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (col, costly) in (('aa', 'bb')) and (col, `name`) in (('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"dd\"))" - ], + "Values": "(VARBINARY(\"dd\"))", "Vindex": "name_user_map" } } @@ -474,9 +436,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (col, `name`) in (('aa', 'bb')) and id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -493,9 +453,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (col, `name`) in (('aa', 'bb')) and id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -516,10 +474,8 @@ Gen4 plan same as above "Query": "select id from `user` where (costly, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", "Values": [ - [ - "bb", - "dd" - ] + "bb", + "dd" ], "Vindex": "name_user_map" } @@ -537,9 +493,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (costly, `name`) in (('aa', 'bb'), ('cc', 'dd'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))" - ], + "Values": "(VARBINARY(\"bb\"), VARBINARY(\"dd\"))", "Vindex": "name_user_map" } } @@ -560,10 +514,8 @@ Gen4 plan same as above "Query": "select id from `user` where ((col1, `name`), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))", "Table": "`user`", "Values": [ - [ - "bb", - "ee" - ] + "bb", + "ee" ], "Vindex": "name_user_map" } @@ -581,9 +533,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where ((col1, `name`), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"bb\"), VARBINARY(\"ee\"))" - ], + "Values": "(VARBINARY(\"bb\"), VARBINARY(\"ee\"))", "Vindex": "name_user_map" } } @@ -604,10 +554,8 @@ Gen4 plan same as above "Query": "select id from `user` where (`name`, (col1, col2)) in (('aa', ('bb', 'cc')), ('dd', ('ee', 'ff')))", "Table": "`user`", "Values": [ - [ - "aa", - "dd" - ] + "aa", + "dd" ], "Vindex": "name_user_map" } @@ -625,9 +573,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (`name`, (col1, col2)) in (('aa', ('bb', 'cc')), ('dd', ('ee', 'ff')))", "Table": "`user`", - "Values": [ - "(VARBINARY(\"aa\"), VARBINARY(\"dd\"))" - ], + "Values": "(VARBINARY(\"aa\"), VARBINARY(\"dd\"))", "Vindex": "name_user_map" } } @@ -700,9 +646,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (col1, `name`) in (('aa', 1 + 1))", "Table": "`user`", - "Values": [ - "(INT64(2))" - ], + "Values": "(INT64(2))", "Vindex": "name_user_map" } } @@ -760,9 +704,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `name` = :a", "Table": "`user`", - "Values": [ - ":a" - ], + "Values": ":a", "Vindex": "name_user_map" } } @@ -783,9 +725,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `name` = 18446744073709551615", "Table": "`user`", - "Values": [ - 18446744073709551615 - ], + "Values": 18446744073709551615, "Vindex": "name_user_map" } } @@ -820,9 +760,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `name` in ::__vals", "Table": "`user`", - "Values": [ - "::list" - ], + "Values": "::list", "Vindex": "name_user_map" } } @@ -839,9 +777,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `name` in ::__vals", "Table": "`user`", - "Values": [ - ":list" - ], + "Values": ":list", "Vindex": "name_user_map" } } @@ -861,9 +797,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user` join user_extra on `user`.id = user_extra.user_id where 1 != 1", "Query": "select user_extra.id from `user` join user_extra on `user`.id = user_extra.user_id where `user`.id = 5", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -880,9 +814,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user`, user_extra where 1 != 1", "Query": "select user_extra.id from `user`, user_extra where `user`.id = 5 and `user`.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -902,9 +834,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user` join user_extra on `user`.id = user_extra.user_id where 1 != 1", "Query": "select user_extra.id from `user` join user_extra on `user`.id = user_extra.user_id where user_extra.user_id = 5", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -921,9 +851,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user`, user_extra where 1 != 1", "Query": "select user_extra.id from `user`, user_extra where user_extra.user_id = 5 and `user`.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -943,9 +871,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where 1 != 1", "Query": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where `user`.id = 5", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -962,9 +888,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where 1 != 1", "Query": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where `user`.id = 5", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -984,9 +908,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where 1 != 1", "Query": "select user_extra.id from `user` left join user_extra on `user`.id = user_extra.user_id where user_extra.user_id = 5", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1003,9 +925,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user`, user_extra where 1 != 1", "Query": "select user_extra.id from `user`, user_extra where user_extra.user_id = 5 and `user`.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1034,9 +954,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -1076,9 +994,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -1120,9 +1036,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -1135,9 +1049,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = 5", "Table": "user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } ] @@ -1156,9 +1068,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from `user`, user_extra where 1 != 1", "Query": "select user_extra.id from `user`, user_extra where `user`.id = 5 and user_extra.user_id = 5 and `user`.col = user_extra.col", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1198,9 +1108,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = :user_col", "Table": "user_extra", - "Values": [ - ":user_col" - ], + "Values": ":user_col", "Vindex": "user_index" } ] @@ -1240,9 +1148,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = :user_col", "Table": "user_extra", - "Values": [ - ":user_col" - ], + "Values": ":user_col", "Vindex": "user_index" } ] @@ -1343,10 +1249,8 @@ Gen4 plan same as above "Query": "select id from `user` where `user`.col = 5 and `user`.id in ::__vals", "Table": "`user`", "Values": [ - [ - 1, - 2 - ] + 1, + 2 ], "Vindex": "user_index" } @@ -1364,9 +1268,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = 5 and `user`.id in ::__vals", "Table": "`user`", - "Values": [ - "(INT64(1), INT64(2))" - ], + "Values": "(INT64(1), INT64(2))", "Vindex": "user_index" } } @@ -1387,10 +1289,8 @@ Gen4 plan same as above "Query": "select id from `user` where `user`.col = case `user`.col when 'foo' then true else false end and `user`.id in ::__vals", "Table": "`user`", "Values": [ - [ - 1, - 2 - ] + 1, + 2 ], "Vindex": "user_index" } @@ -1408,9 +1308,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = case `user`.col when 'foo' then true else false end and `user`.id in ::__vals", "Table": "`user`", - "Values": [ - "(INT64(1), INT64(2))" - ], + "Values": "(INT64(1), INT64(2))", "Vindex": "user_index" } } @@ -1430,9 +1328,7 @@ Gen4 plan same as above "FieldQuery": "select id or col as val from `user` where 1 != 1", "Query": "select id or col as val from `user` where `user`.col = 5 and `user`.id in (1, 2) and `user`.`name` = 'aa'", "Table": "`user`", - "Values": [ - "aa" - ], + "Values": "aa", "Vindex": "name_user_map" } } @@ -1449,9 +1345,7 @@ Gen4 plan same as above "FieldQuery": "select id or col as val from `user` where 1 != 1", "Query": "select id or col as val from `user` where `user`.col = 5 and `user`.id in (1, 2) and `user`.`name` = 'aa'", "Table": "`user`", - "Values": [ - "VARBINARY(\"aa\")" - ], + "Values": "VARBINARY(\"aa\")", "Vindex": "name_user_map" } } @@ -1471,9 +1365,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = false and `user`.id in (1, 2) and `user`.`name` = 'aa'", "Table": "`user`", - "Values": [ - "aa" - ], + "Values": "aa", "Vindex": "name_user_map" } } @@ -1490,9 +1382,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = false and `user`.id in (1, 2) and `user`.`name` = 'aa'", "Table": "`user`", - "Values": [ - "VARBINARY(\"aa\")" - ], + "Values": "VARBINARY(\"aa\")", "Vindex": "name_user_map" } } @@ -1512,9 +1402,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = 5 and `user`.id in (1, 2) and `user`.`name` = 'aa' and `user`.id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1531,9 +1419,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.col = 5 and `user`.id in (1, 2) and `user`.`name` = 'aa' and `user`.id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1553,9 +1439,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = 1 and `user`.`name` = 'aa' and `user`.id in (1, 2) and `user`.col = 5", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1572,9 +1456,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = 1 and `user`.`name` = 'aa' and `user`.id in (1, 2) and `user`.col = 5", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1671,9 +1553,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where `user`.id = :unsharded_id", "Table": "`user`", - "Values": [ - ":unsharded_id" - ], + "Values": ":unsharded_id", "Vindex": "user_index" } ] @@ -1695,9 +1575,7 @@ Gen4 plan same as above "FieldQuery": "select col from `user` as route1 where 1 != 1", "Query": "select col from `user` as route1 where id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1714,9 +1592,7 @@ Gen4 plan same as above "FieldQuery": "select col from `user` as route1 where 1 != 1", "Query": "select col from `user` as route1 where id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1757,10 +1633,8 @@ Gen4 plan same as above "Query": "select u.m from `user` as u where u.id in ::__vals and u.id in (select m2 from `user` where `user`.id = u.id and `user`.col = :user_extra_col)", "Table": "`user`", "Values": [ - [ - ":user_extra_col", - 1 - ] + ":user_extra_col", + 1 ], "Vindex": "user_index" } @@ -1801,9 +1675,7 @@ Gen4 plan same as above "FieldQuery": "select u.m from `user` as u where 1 != 1", "Query": "select u.m from `user` as u where u.id in (select m2 from `user` where `user`.id = u.id and `user`.col = :user_extra_col) and u.id in ::__vals", "Table": "`user`", - "Values": [ - "(:user_extra_col, INT64(1))" - ], + "Values": "(:user_extra_col, INT64(1))", "Vindex": "user_index" } ] @@ -1846,10 +1718,8 @@ Gen4 plan same as above "Query": "select u.m from `user` as u where u.id in ::__vals and u.id in (select m2 from `user` where `user`.id = u.id)", "Table": "`user`", "Values": [ - [ - ":user_extra_col", - 1 - ] + ":user_extra_col", + 1 ], "Vindex": "user_index" } @@ -1890,9 +1760,7 @@ Gen4 plan same as above "FieldQuery": "select u.m from `user` as u where 1 != 1", "Query": "select u.m from `user` as u where u.id in (select m2 from `user` where `user`.id = u.id) and u.id in ::__vals", "Table": "`user`", - "Values": [ - "(:user_extra_col, INT64(1))" - ], + "Values": "(:user_extra_col, INT64(1))", "Vindex": "user_index" } ] @@ -1931,9 +1799,7 @@ Gen4 plan same as above "FieldQuery": "select u.m from `user` as u where 1 != 1", "Query": "select u.m from `user` as u where u.id = 5 and u.id in (select m2 from `user` where `user`.id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } ] @@ -1969,9 +1835,7 @@ Gen4 plan same as above "FieldQuery": "select u.m from `user` as u where 1 != 1", "Query": "select u.m from `user` as u where u.id in (select m2 from `user` where `user`.id = 5) and u.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } ] @@ -2014,10 +1878,8 @@ Gen4 plan same as above "Query": "select u.m from `user` as u where u.id in ::__vals and u.id in (select m2 from `user` where `user`.id = u.id and `user`.col = :user_extra_col and `user`.id in (select m3 from user_extra where user_extra.user_id = `user`.id))", "Table": "`user`", "Values": [ - [ - ":user_extra_col", - 1 - ] + ":user_extra_col", + 1 ], "Vindex": "user_index" } @@ -2058,9 +1920,7 @@ Gen4 plan same as above "FieldQuery": "select u.m from `user` as u where 1 != 1", "Query": "select u.m from `user` as u where u.id in (select m2 from `user` where `user`.id = u.id and `user`.col = :user_extra_col and `user`.id in (select m3 from user_extra where user_extra.user_id = `user`.id)) and u.id in ::__vals", "Table": "`user`", - "Values": [ - "(:user_extra_col, INT64(1))" - ], + "Values": "(:user_extra_col, INT64(1))", "Vindex": "user_index" } ] @@ -2101,9 +1961,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and `user`.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2120,9 +1978,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and `user`.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2142,9 +1998,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 'aa' and `user`.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "Table": "`user`", - "Values": [ - "aa" - ], + "Values": "aa", "Vindex": "user_index" } } @@ -2161,9 +2015,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 'aa' and `user`.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "Table": "`user`", - "Values": [ - "VARBINARY(\"aa\")" - ], + "Values": "VARBINARY(\"aa\")", "Vindex": "user_index" } } @@ -2183,9 +2035,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = :a and `user`.col in (select user_extra.col from user_extra where user_extra.user_id = :a)", "Table": "`user`", - "Values": [ - ":a" - ], + "Values": ":a", "Vindex": "user_index" } } @@ -2250,9 +2100,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -2290,9 +2138,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -2447,9 +2293,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = :__sq1", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -2512,9 +2356,7 @@ Gen4 plan same as above "FieldQuery": "select id1 from `user` where 1 != 1", "Query": "select id1 from `user` where id = :__sq2", "Table": "`user`", - "Values": [ - ":__sq2" - ], + "Values": ":__sq2", "Vindex": "user_index" } ] @@ -2573,9 +2415,7 @@ Gen4 plan same as above "FieldQuery": "select id1 from `user` where 1 != 1", "Query": "select id1 from `user` where id = :__sq1", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -2635,9 +2475,7 @@ Gen4 plan same as above "FieldQuery": "select col from `user` where 1 != 1", "Query": "select col from `user` where id = :__sq1", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -2660,9 +2498,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.Id from `user` join user_extra on `user`.iD = user_extra.User_Id where 1 != 1", "Query": "select user_extra.Id from `user` join user_extra on `user`.iD = user_extra.User_Id where `user`.Id = 5", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2679,9 +2515,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.Id from `user`, user_extra where 1 != 1", "Query": "select user_extra.Id from `user`, user_extra where `user`.Id = 5 and `user`.iD = user_extra.User_Id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2739,9 +2573,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id is null", "Table": "music", - "Values": [ - null - ], + "Values": null, "Vindex": "music_user_map" } } @@ -2758,9 +2590,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id is null", "Table": "music", - "Values": [ - "NULL" - ], + "Values": "NULL", "Vindex": "music_user_map" } } @@ -2837,9 +2667,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where user_id = 4 and id in (null, 1, 2)", "Table": "music", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" } } @@ -2856,9 +2684,7 @@ Gen4 plan same as above "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where user_id = 4 and id in (null, 1, 2)", "Table": "music", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" } } @@ -2924,9 +2750,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 42", "Table": "user_extra", - "Values": [ - 42 - ], + "Values": 42, "Vindex": "user_index" }, { @@ -2947,9 +2771,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 411", "Table": "user_extra", - "Values": [ - 411 - ], + "Values": 411, "Vindex": "user_index" }, { @@ -2962,9 +2784,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals and (:__sq_has_values2 = 0 or id not in ::__sq2)", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -2993,9 +2813,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 411", "Table": "user_extra", - "Values": [ - "INT64(411)" - ], + "Values": "INT64(411)", "Vindex": "user_index" }, { @@ -3016,9 +2834,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 42", "Table": "user_extra", - "Values": [ - "INT64(42)" - ], + "Values": "INT64(42)", "Vindex": "user_index" }, { @@ -3031,9 +2847,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where (:__sq_has_values1 = 0 or id not in ::__sq1) and (:__sq_has_values2 = 1 and id in ::__vals)", "Table": "`user`", - "Values": [ - ":__sq2" - ], + "Values": ":__sq2", "Vindex": "user_index" } ] @@ -3057,9 +2871,7 @@ Gen4 plan same as above "FieldQuery": "select c2 from cfc_vindex_col where 1 != 1", "Query": "select c2 from cfc_vindex_col where c1 like 'A%'", "Table": "cfc_vindex_col", - "Values": [ - "A%" - ], + "Values": "A%", "Vindex": "cfc" } } @@ -3076,9 +2888,7 @@ Gen4 plan same as above "FieldQuery": "select c2 from cfc_vindex_col where 1 != 1", "Query": "select c2 from cfc_vindex_col where c1 like 'A%'", "Table": "cfc_vindex_col", - "Values": [ - "VARBINARY(\"A%\")" - ], + "Values": "VARBINARY(\"A%\")", "Vindex": "cfc" } } @@ -3097,9 +2907,7 @@ Gen4 plan same as above "FieldQuery": "select col from samecolvin where 1 != 1", "Query": "select col from samecolvin where col = :col", "Table": "samecolvin", - "Values": [ - ":col" - ], + "Values": ":col", "Vindex": "vindex1" } } @@ -3177,9 +2985,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -3217,9 +3023,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -3303,9 +3107,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and u1.`name` in (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -3322,9 +3124,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and u1.`name` in (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -3344,9 +3144,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and exists (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -3363,9 +3161,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and exists (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -3385,9 +3181,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and not exists (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -3404,9 +3198,7 @@ Gen4 plan same as above "FieldQuery": "select u1.col from `user` as u1 where 1 != 1", "Query": "select u1.col from `user` as u1 where u1.id = 5 and not exists (select u2.`name` from `user` as u2 where u2.id = 5)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -3434,9 +3226,7 @@ Gen4 plan same as above "FieldQuery": "select u2.`name` from `user` as u2 where 1 != 1", "Query": "select u2.`name` from `user` as u2 where u2.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -3473,9 +3263,7 @@ Gen4 plan same as above "FieldQuery": "select u2.`name` from `user` as u2 where 1 != 1", "Query": "select u2.`name` from `user` as u2 where u2.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -3516,9 +3304,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 4", "Table": "user_extra", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" }, { @@ -3531,9 +3317,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and :__sq_has_values1 = 1 and id in ::__sq1 and id not in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } ] @@ -3560,9 +3344,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 4", "Table": "user_extra", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" }, { @@ -3575,9 +3357,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and id not in (select user_extra.col from user_extra where user_extra.user_id = 5) and (:__sq_has_values2 = 1 and id in ::__sq2)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } ] @@ -3607,9 +3387,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 4", "Table": "user_extra", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" }, { @@ -3622,9 +3400,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and id in (select user_extra.col from user_extra where user_extra.user_id = 5) and (:__sq_has_values1 = 0 or id not in ::__sq1)", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } ] @@ -3651,9 +3427,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra where user_extra.user_id = 4", "Table": "user_extra", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" }, { @@ -3666,9 +3440,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5 and (:__sq_has_values1 = 0 or id not in ::__sq1) and id in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } ] @@ -3738,9 +3510,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = `user`.col and `user`.col = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -3873,9 +3643,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where `user`.id = :user_extra_col", "Table": "`user`", - "Values": [ - ":user_extra_col" - ], + "Values": ":user_extra_col", "Vindex": "user_index" } ] @@ -4047,9 +3815,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1", "Table": "multicolvin", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "colb_colc_map" } } @@ -4066,9 +3832,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1", "Table": "multicolvin", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "colb_colc_map" } } @@ -4088,9 +3852,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1 and column_c = 2", "Table": "multicolvin", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "colb_colc_map" } } @@ -4107,9 +3869,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1 and column_c = 2", "Table": "multicolvin", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "colb_colc_map" } } @@ -4129,9 +3889,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3", "Table": "multicolvin", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "colb_colc_map" } } @@ -4148,9 +3906,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3", "Table": "multicolvin", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "colb_colc_map" } } @@ -4170,9 +3926,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_a = 3 and column_b = 1", "Table": "multicolvin", - "Values": [ - 3 - ], + "Values": 3, "Vindex": "cola_map" } } @@ -4189,9 +3943,7 @@ Gen4 plan same as above "FieldQuery": "select * from multicolvin where 1 != 1", "Query": "select * from multicolvin where column_a = 3 and column_b = 1", "Table": "multicolvin", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "colb_colc_map" } } @@ -4239,9 +3991,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -4279,9 +4029,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index 40b35765a4d..105e673d3c0 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -132,9 +132,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -443,9 +441,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where `user`.id = :music_id", "Table": "`user`", - "Values": [ - ":music_id" - ], + "Values": ":music_id", "Vindex": "user_index" } ] @@ -485,9 +481,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where `user`.id = :music_id", "Table": "`user`", - "Values": [ - ":music_id" - ], + "Values": ":music_id", "Vindex": "user_index" } ] @@ -1431,9 +1425,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` join user_extra on `user`.id = 5 and `user`.id = user_extra.user_id where 1 != 1", "Query": "select `user`.col from `user` join user_extra on `user`.id = 5 and `user`.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1450,9 +1442,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user`, user_extra where 1 != 1", "Query": "select `user`.col from `user`, user_extra where `user`.id = 5 and `user`.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1556,9 +1546,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -1594,9 +1582,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -1635,9 +1621,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -1673,9 +1657,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -1766,9 +1748,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.id = :user_extra_col", "Table": "`user`", - "Values": [ - ":user_extra_col" - ], + "Values": ":user_extra_col", "Vindex": "user_index" } ] @@ -1810,9 +1790,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col from `user` where 1 != 1", "Query": "select `user`.col from `user` where `user`.`name` = :user_extra_user_id", "Table": "`user`", - "Values": [ - ":user_extra_user_id" - ], + "Values": ":user_extra_user_id", "Vindex": "name_user_map" } ] @@ -1852,9 +1830,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.user_id = :user_name", "Table": "user_extra", - "Values": [ - ":user_name" - ], + "Values": ":user_name", "Vindex": "user_index" } ] @@ -1976,9 +1952,7 @@ Gen4 plan same as above "FieldQuery": "select ref.col from ref join (select aa from `user` where 1 != 1) as `user` where 1 != 1", "Query": "select ref.col from ref join (select aa from `user` where `user`.id = 1) as `user`", "Table": "`user`, ref", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1995,9 +1969,7 @@ Gen4 plan same as above "FieldQuery": "select ref.col from ref, (select aa from `user` where 1 != 1) as `user` where 1 != 1", "Query": "select ref.col from ref, (select aa from `user` where `user`.id = 1) as `user`", "Table": "`user`, ref", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -2055,9 +2027,7 @@ Gen4 plan same as above "FieldQuery": "select id from (select id, col from `user` where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` where id = 5) as t", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2074,9 +2044,7 @@ Gen4 plan same as above "FieldQuery": "select id from (select id, col from `user` where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` where id = 5) as t", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2096,9 +2064,7 @@ Gen4 plan same as above "FieldQuery": "select t.id from (select id from `user` where 1 != 1) as t join user_extra on t.id = user_extra.user_id where 1 != 1", "Query": "select t.id from (select id from `user` where id = 5) as t join user_extra on t.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2115,9 +2081,7 @@ Gen4 plan same as above "FieldQuery": "select t.id from (select id from `user` where 1 != 1) as t, user_extra where 1 != 1", "Query": "select t.id from (select id from `user` where id = 5) as t, user_extra where t.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2137,9 +2101,7 @@ Gen4 plan same as above "FieldQuery": "select t.id from (select `user`.id from `user` where 1 != 1) as t join user_extra on t.id = user_extra.user_id where 1 != 1", "Query": "select t.id from (select `user`.id from `user` where `user`.id = 5) as t join user_extra on t.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2156,9 +2118,7 @@ Gen4 plan same as above "FieldQuery": "select t.id from (select `user`.id from `user` where 1 != 1) as t, user_extra where 1 != 1", "Query": "select t.id from (select `user`.id from `user` where `user`.id = 5) as t, user_extra where t.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2198,9 +2158,7 @@ Gen4 error: Duplicate column name 'id' "FieldQuery": "select t.id from user_extra, (select id from `user` where 1 != 1) as t where 1 != 1", "Query": "select t.id from user_extra, (select id from `user` where id = 5) as t where t.id = user_extra.user_id", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2229,9 +2187,7 @@ Gen4 error: Duplicate column name 'id' "FieldQuery": "select t.id from (select id from `user` where 1 != 1) as t where 1 != 1", "Query": "select t.id from (select id from `user` where id = 5) as t", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" }, { @@ -2271,9 +2227,7 @@ Gen4 error: Duplicate column name 'id' "FieldQuery": "select t.id from (select id from `user` where 1 != 1) as t where 1 != 1", "Query": "select t.id from (select id from `user` where id = 5) as t", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -2306,9 +2260,7 @@ Gen4 error: Duplicate column name 'id' "FieldQuery": "select id from (select id, col from `user` as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` as route1 where id = 5) as t", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2325,9 +2277,7 @@ Gen4 error: Duplicate column name 'id' "FieldQuery": "select id from (select id, col from `user` as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` as route1 where id = 5) as t", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2366,9 +2316,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select id from (select id, col from `user` as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` as route1) as t where id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2385,9 +2333,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select id from (select id, col from `user` as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from `user` as route1 where id = 5) as t", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2492,9 +2438,7 @@ Gen4 error: symbol id not found "FieldQuery": "select id from (select id from (select id from `user` where 1 != 1) as u where 1 != 1) as t where 1 != 1", "Query": "select id from (select id from (select id from `user`) as u) as t where id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2511,9 +2455,7 @@ Gen4 error: symbol id not found "FieldQuery": "select id from (select id from (select id from `user` where 1 != 1) as u where 1 != 1) as t where 1 != 1", "Query": "select id from (select id from (select id from `user` where id = 5) as u) as t", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2533,9 +2475,7 @@ Gen4 error: symbol id not found "FieldQuery": "select u.col, e.col from (select col from `user` where 1 != 1) as u join (select col from user_extra where 1 != 1) as e where 1 != 1", "Query": "select u.col, e.col from (select col from `user` where id = 5) as u join (select col from user_extra where user_id = 5) as e", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -2552,9 +2492,7 @@ Gen4 error: symbol id not found "FieldQuery": "select u.col, e.col from (select col from `user` where 1 != 1) as u, (select col from user_extra where 1 != 1) as e where 1 != 1", "Query": "select u.col, e.col from (select col from `user` where id = 5) as u, (select col from user_extra where user_id = 5) as e", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -2980,9 +2918,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id, `user`.col1 from `user` where 1 != 1", "Query": "select `user`.id, `user`.col1 from `user` where `user`.id = :ua_id", "Table": "`user`", - "Values": [ - ":ua_id" - ], + "Values": ":ua_id", "Vindex": "user_index" }, { @@ -3878,9 +3814,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id from `user` where 1 != 1", "Query": "select `user`.id from `user` where `user`.id = :user_extra_id", "Table": "`user`", - "Values": [ - ":user_extra_id" - ], + "Values": ":user_extra_id", "Vindex": "user_index" } ] @@ -3922,9 +3856,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.assembly_id = :user_id and user_extra.user_id = 2", "Table": "user_extra", - "Values": [ - 2 - ], + "Values": 2, "Vindex": "user_index" } ] @@ -3953,9 +3885,7 @@ Gen4 plan same as above "FieldQuery": "select user_extra.assembly_id from user_extra where 1 != 1", "Query": "select user_extra.assembly_id from user_extra where user_extra.user_id = 2", "Table": "user_extra", - "Values": [ - "INT64(2)" - ], + "Values": "INT64(2)", "Vindex": "user_index" }, { @@ -3968,9 +3898,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id from `user` where 1 != 1", "Query": "select `user`.id from `user` where `user`.id = :user_extra_assembly_id", "Table": "`user`", - "Values": [ - ":user_extra_assembly_id" - ], + "Values": ":user_extra_assembly_id", "Vindex": "user_index" } ] @@ -4112,9 +4040,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from music as m where 1 != 1", "Query": "select 1 from music as m where m.user_id = :ue_user_id", "Table": "music", - "Values": [ - ":ue_user_id" - ], + "Values": ":ue_user_id", "Vindex": "user_index" } ] @@ -4154,9 +4080,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` as u where 1 != 1", "Query": "select 1 from `user` as u where u.id = :ue_id", "Table": "`user`", - "Values": [ - ":ue_id" - ], + "Values": ":ue_id", "Vindex": "user_index" } ] @@ -4236,9 +4160,7 @@ Gen4 plan same as above "FieldQuery": "select u.id as uid from `user` as u where 1 != 1", "Query": "select u.id as uid from `user` as u where u.id = :ue_id", "Table": "`user`", - "Values": [ - ":ue_id" - ], + "Values": ":ue_id", "Vindex": "user_index" } ] @@ -4355,9 +4277,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id, `user`.col from `user` where 1 != 1", "Query": "select `user`.id, `user`.col from `user` where `user`.id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" }, { @@ -4439,9 +4359,7 @@ Gen4 plan same as above "FieldQuery": "select u.a from (select id as b, `name` from `user` where 1 != 1) as u(a, n) where 1 != 1", "Query": "select u.a from (select id as b, `name` from `user` where `name` = 1) as u(a, n)", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "name_user_map" } } @@ -4462,9 +4380,7 @@ Gen4 plan same as above "FieldQuery": "select u.a from (select id as b, `name` from `user` where 1 != 1) as u(a, n) where 1 != 1", "Query": "select u.a from (select id as b, `name` from `user` where b = 1 and `name` = 1) as u(a, n)", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "name_user_map" } } @@ -4574,9 +4490,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where col = :__sq1 and :__sq_has_values2 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq2" - ], + "Values": "::__sq2", "Vindex": "user_index" } ] @@ -4641,9 +4555,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals and col = :__sq2", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/large_cases.txt b/go/vt/vtgate/planbuilder/testdata/large_cases.txt index 1a3974a70a7..b5c8be8d960 100644 --- a/go/vt/vtgate/planbuilder/testdata/large_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/large_cases.txt @@ -40,9 +40,7 @@ "FieldQuery": "select user_extra.user_id from user_extra where 1 != 1", "Query": "select user_extra.user_id from user_extra where user_extra.user_id = :user_id", "Table": "user_extra", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "user_index" }, { @@ -60,9 +58,7 @@ "FieldQuery": "select 1 from user_metadata where 1 != 1", "Query": "select 1 from user_metadata where user_metadata.user_id = :user_extra_user_id", "Table": "user_metadata", - "Values": [ - ":user_extra_user_id" - ], + "Values": ":user_extra_user_id", "Vindex": "user_index" }, { @@ -161,9 +157,7 @@ "FieldQuery": "select 1 from music_extra where 1 != 1", "Query": "select 1 from music_extra where music_extra.music_id = :music_id", "Table": "music_extra", - "Values": [ - ":music_id" - ], + "Values": ":music_id", "Vindex": "music_user_map" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt index c1055cd05cc..07469024e3a 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt @@ -395,9 +395,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select `user`.col1 as a, `user`.col2 as b, `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2 as b, `user`.id from `user` where `user`.id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -410,9 +408,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select music.col3 as c, weight_string(music.col3) from music where 1 != 1", "Query": "select music.col3 as c, weight_string(music.col3) from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -449,9 +445,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select `user`.id, `user`.col1 as a, `user`.col2 as b from `user` where 1 != 1", "Query": "select `user`.id, `user`.col1 as a, `user`.col2 as b from `user` where `user`.id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -464,9 +458,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select music.col3 as c, weight_string(music.col3) from music where 1 != 1", "Query": "select music.col3 as c, weight_string(music.col3) from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -505,9 +497,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select `user`.col1 as a, `user`.col2, weight_string(`user`.col1), weight_string(`user`.col2), `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2, weight_string(`user`.col1), weight_string(`user`.col2), `user`.id from `user` where `user`.id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -520,9 +510,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select music.col3, weight_string(music.col3) from music where 1 != 1", "Query": "select music.col3, weight_string(music.col3) from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -559,9 +547,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select `user`.id, `user`.col1 as a, `user`.col2, weight_string(`user`.col1), weight_string(`user`.col2) from `user` where 1 != 1", "Query": "select `user`.id, `user`.col1 as a, `user`.col2, weight_string(`user`.col1), weight_string(`user`.col2) from `user` where `user`.id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -574,9 +560,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "FieldQuery": "select music.col3, weight_string(music.col3) from music where 1 != 1", "Query": "select music.col3, weight_string(music.col3) from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt b/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt index de1ec576112..7510afbd532 100644 --- a/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt @@ -13,9 +13,7 @@ "FieldQuery": "select c from sbtest34 where 1 != 1", "Query": "select c from sbtest34 where id = 15", "Table": "sbtest34", - "Values": [ - 15 - ], + "Values": 15, "Vindex": "hash" } } @@ -32,9 +30,7 @@ "FieldQuery": "select c from sbtest34 where 1 != 1", "Query": "select c from sbtest34 where id = 15", "Table": "sbtest34", - "Values": [ - "INT64(15)" - ], + "Values": "INT64(15)", "Vindex": "hash" } } diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt index 43126792db6..056734427f6 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt @@ -213,9 +213,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` having :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -253,9 +251,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ] @@ -277,9 +273,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select col from `user` where 1 != 1", "Query": "select col from `user` where id = 5 order by aa asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -296,9 +290,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select col from `user` where 1 != 1", "Query": "select col from `user` where id = 5 order by aa asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -318,9 +310,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select col from `user` where 1 != 1", "Query": "select col from `user` where id = 1 order by 1 asc", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -337,9 +327,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "FieldQuery": "select col from `user` where 1 != 1", "Query": "select col from `user` where id = 1 order by col asc", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -679,9 +667,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where `user`.id = 1 order by null", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -694,9 +680,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id order by null", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -725,9 +709,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where 1 != 1", "Query": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where `user`.id = 1 order by null", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -740,9 +722,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id order by null", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -773,9 +753,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where `user`.id = 1 order by a asc", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -788,9 +766,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -820,9 +796,7 @@ Gen4 plan same as above "OrderBy": "(1|3) ASC", "Query": "select `user`.id, `user`.col1 as a, `user`.col2, weight_string(`user`.col1) from `user` where `user`.id = 1 order by a asc", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -835,9 +809,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -868,9 +840,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where `user`.id = 1 order by a asc", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -883,9 +853,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -915,9 +883,7 @@ Gen4 plan same as above "OrderBy": "(1|3) ASC", "Query": "select `user`.id, `user`.col1 as a, `user`.col2, weight_string(`user`.col1) from `user` where `user`.id = 1 order by a asc", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -930,9 +896,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -1022,9 +986,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where 1 != 1", "Query": "select `user`.col1 as a, `user`.col2, `user`.id from `user` where `user`.id = 1 order by RAND()", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -1037,9 +999,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id order by RAND()", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -1068,9 +1028,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where 1 != 1", "Query": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where `user`.id = 1 order by RAND()", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -1083,9 +1041,7 @@ Gen4 plan same as above "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id order by RAND()", "Table": "music", - "Values": [ - ":user_id" - ], + "Values": ":user_id", "Vindex": "music_user_map" } ] @@ -1147,9 +1103,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by col asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1166,9 +1120,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by col asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1188,9 +1140,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.* from `user` where 1 != 1", "Query": "select `user`.* from `user` where id = 5 order by `user`.col asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1207,9 +1157,7 @@ Gen4 plan same as above "FieldQuery": "select `user`.* from `user` where 1 != 1", "Query": "select `user`.* from `user` where id = 5 order by `user`.col asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1229,9 +1177,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by `user`.col asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1248,9 +1194,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by `user`.col asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1382,9 +1326,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by `user`.col collate utf8_general_ci asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1401,9 +1343,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by `user`.col collate utf8_general_ci asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1423,9 +1363,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by -col1 asc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1442,9 +1380,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by -col1 asc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1464,9 +1400,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by concat(col, col1) collate utf8_general_ci desc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1483,9 +1417,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by concat(col, col1) collate utf8_general_ci desc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1505,9 +1437,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by id + col collate utf8_general_ci desc", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1524,9 +1454,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 order by id + col collate utf8_general_ci desc", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1546,9 +1474,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` as u join (select user_id from user_extra where 1 != 1) as eu on u.id = eu.user_id where 1 != 1", "Query": "select * from `user` as u join (select user_id from user_extra where user_id = 5) as eu on u.id = eu.user_id where u.id = 5 order by eu.user_id asc", "Table": "`user`, user_extra", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1565,9 +1491,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` as u, (select user_id from user_extra where 1 != 1) as eu where 1 != 1", "Query": "select * from `user` as u, (select user_id from user_extra where user_id = 5) as eu where u.id = 5 and u.id = eu.user_id order by eu.user_id asc", "Table": "`user`, user_extra", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1587,9 +1511,7 @@ Gen4 plan same as above "FieldQuery": "select col from `user` as route1 where 1 != 1", "Query": "select col from `user` as route1 where id = 1 order by col asc", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1606,9 +1528,7 @@ Gen4 plan same as above "FieldQuery": "select col from `user` as route1 where 1 != 1", "Query": "select col from `user` as route1 where id = 1 order by col asc", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1628,9 +1548,7 @@ Gen4 plan same as above "FieldQuery": "select col1 from `user` where 1 != 1", "Query": "select col1 from `user` where id = 1 limit 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1647,9 +1565,7 @@ Gen4 plan same as above "FieldQuery": "select col1 from `user` where 1 != 1", "Query": "select col1 from `user` where id = 1 limit 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } diff --git a/go/vt/vtgate/planbuilder/testdata/rails_cases.txt b/go/vt/vtgate/planbuilder/testdata/rails_cases.txt index 6414bca70bd..2704be90ef7 100644 --- a/go/vt/vtgate/planbuilder/testdata/rails_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/rails_cases.txt @@ -60,9 +60,7 @@ "FieldQuery": "select book6s_order2s.order2_id from book6s_order2s where 1 != 1", "Query": "select book6s_order2s.order2_id from book6s_order2s where book6s_order2s.book6_id = :book6s_id", "Table": "book6s_order2s", - "Values": [ - ":book6s_id" - ], + "Values": ":book6s_id", "Vindex": "binary_md5" } ] @@ -90,9 +88,7 @@ "FieldQuery": "select 1 from customer2s where 1 != 1", "Query": "select 1 from customer2s where customer2s.id = :order2s_customer2_id", "Table": "customer2s", - "Values": [ - ":order2s_customer2_id" - ], + "Values": ":order2s_customer2_id", "Vindex": "binary_md5" } ] @@ -107,9 +103,7 @@ "FieldQuery": "select 1 from supplier5s where 1 != 1", "Query": "select 1 from supplier5s where supplier5s.id = :book6s_supplier5_id", "Table": "supplier5s", - "Values": [ - ":book6s_supplier5_id" - ], + "Values": ":book6s_supplier5_id", "Vindex": "binary_md5" } ] @@ -180,9 +174,7 @@ "FieldQuery": "select 1 from book6s_order2s where 1 != 1", "Query": "select 1 from book6s_order2s where book6s_order2s.book6_id = :book6s_id and book6s_order2s.order2_id = :order2s_id", "Table": "book6s_order2s", - "Values": [ - ":book6s_id" - ], + "Values": ":book6s_id", "Vindex": "binary_md5" } ] @@ -197,9 +189,7 @@ "FieldQuery": "select 1 from supplier5s where 1 != 1", "Query": "select 1 from supplier5s where supplier5s.id = :book6s_supplier5_id", "Table": "supplier5s", - "Values": [ - ":book6s_supplier5_id" - ], + "Values": ":book6s_supplier5_id", "Vindex": "binary_md5" } ] @@ -270,9 +260,7 @@ "FieldQuery": "select book6s_order2s.order2_id from book6s_order2s where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ book6s_order2s.order2_id from book6s_order2s where book6s_order2s.book6_id = :book6s_id", "Table": "book6s_order2s", - "Values": [ - ":book6s_id" - ], + "Values": ":book6s_id", "Vindex": "binary_md5" } ] @@ -300,9 +288,7 @@ "FieldQuery": "select 1 from customer2s where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ 1 from customer2s where customer2s.id = :order2s_customer2_id", "Table": "customer2s", - "Values": [ - ":order2s_customer2_id" - ], + "Values": ":order2s_customer2_id", "Vindex": "binary_md5" } ] @@ -317,9 +303,7 @@ "FieldQuery": "select 1 from supplier5s where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ 1 from supplier5s where supplier5s.id = :book6s_supplier5_id", "Table": "supplier5s", - "Values": [ - ":book6s_supplier5_id" - ], + "Values": ":book6s_supplier5_id", "Vindex": "binary_md5" } ] @@ -386,9 +370,7 @@ "FieldQuery": "select book6s_order2s.order2_id from book6s_order2s where 1 != 1", "Query": "select /*vt+ ALLOW_HASH_JOIN */ book6s_order2s.order2_id from book6s_order2s where book6s_order2s.book6_id = :book6s_id", "Table": "book6s_order2s", - "Values": [ - ":book6s_id" - ], + "Values": ":book6s_id", "Vindex": "binary_md5" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index 841847137ae..e3884db6482 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -625,9 +625,7 @@ Gen4 plan same as above "FieldQuery": "select * from pin_test where 1 != 1", "Query": "select * from pin_test", "Table": "pin_test", - "Values": [ - "\ufffd" - ], + "Values": "\ufffd", "Vindex": "binary" } } @@ -644,9 +642,7 @@ Gen4 plan same as above "FieldQuery": "select * from pin_test where 1 != 1", "Query": "select * from pin_test", "Table": "pin_test", - "Values": [ - "VARBINARY(\"\\x80\")" - ], + "Values": "VARBINARY(\"\\x80\")", "Vindex": "binary" } } @@ -1044,9 +1040,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where `name` = 'abc' and id = 4 limit 5", "Table": "`user`", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" } } @@ -1063,9 +1057,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where `name` = 'abc' and id = 4 limit 5", "Table": "`user`", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" } } @@ -1085,9 +1077,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 4 and `name` = 'abc' limit 5", "Table": "`user`", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" } } @@ -1104,9 +1094,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 4 and `name` = 'abc' limit 5", "Table": "`user`", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" } } @@ -1126,9 +1114,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 4 and `name` = 'abc' limit 5", "Table": "`user`", - "Values": [ - 4 - ], + "Values": 4, "Vindex": "user_index" } } @@ -1145,9 +1131,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 4 and `name` = 'abc' limit 5", "Table": "`user`", - "Values": [ - "INT64(4)" - ], + "Values": "INT64(4)", "Vindex": "user_index" } } @@ -1167,9 +1151,7 @@ Gen4 plan same as above "FieldQuery": "select user0_.col as col0_ from `user` as user0_ where 1 != 1", "Query": "select user0_.col as col0_ from `user` as user0_ where id = 1 order by user0_.col desc limit 2", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1186,9 +1168,7 @@ Gen4 plan same as above "FieldQuery": "select user0_.col as col0_ from `user` as user0_ where 1 != 1", "Query": "select user0_.col as col0_ from `user` as user0_ where id = 1 order by user0_.col desc limit 2", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1208,9 +1188,7 @@ Gen4 plan same as above "FieldQuery": "select user0_.col as col0_ from `user` as user0_ where 1 != 1", "Query": "select user0_.col as col0_ from `user` as user0_ where id = 1 order by col0_ desc limit 3", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1227,9 +1205,7 @@ Gen4 plan same as above "FieldQuery": "select user0_.col as col0_ from `user` as user0_ where 1 != 1", "Query": "select user0_.col as col0_ from `user` as user0_ where id = 1 order by col0_ desc limit 3", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1249,9 +1225,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 1 and `name` = true limit 5", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1268,9 +1242,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 1 and `name` = true limit 5", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1290,9 +1262,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 1 and `name` limit 5", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1309,9 +1279,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 1 and `name` limit 5", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1331,9 +1299,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 and `name` = true limit 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } } @@ -1350,9 +1316,7 @@ Gen4 plan same as above "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 5 and `name` = true limit 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } } @@ -1577,9 +1541,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select * from music where 1 != 1 union select * from `user` where 1 != 1", "Query": "select * from music where user_id = 1 union select * from `user` where id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1596,9 +1558,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select * from music where 1 != 1 union select * from `user` where 1 != 1", "Query": "select * from music where user_id = 1 union select * from `user` where id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1618,9 +1578,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select *, :__lastInsertId as `last_insert_id()` from music where 1 != 1 union select * from `user` where 1 != 1", "Query": "select *, :__lastInsertId as `last_insert_id()` from music where user_id = 1 union select * from `user` where id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1637,9 +1595,7 @@ Gen4 error: symbol t.col not found "FieldQuery": "select *, :__lastInsertId as `last_insert_id()` from music where 1 != 1 union select * from `user` where 1 != 1", "Query": "select *, :__lastInsertId as `last_insert_id()` from music where user_id = 1 union select * from `user` where id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -1883,9 +1839,7 @@ Gen4 plan same as above "FieldQuery": "select * from music where 1 != 1", "Query": "select * from music where user_id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -1902,9 +1856,7 @@ Gen4 plan same as above "FieldQuery": "select * from music where 1 != 1", "Query": "select * from music where user_id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -2018,9 +1970,7 @@ Gen4 plan same as above "FieldQuery": "select * from music where 1 != 1", "Query": "select * from music where user_id = 1 limit 2", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -2033,9 +1983,7 @@ Gen4 plan same as above "FieldQuery": "select count(*) from music where 1 != 1", "Query": "select count(*) from music where user_id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } ] @@ -2057,9 +2005,7 @@ Gen4 plan same as above "FieldQuery": "select * from music where 1 != 1", "Query": "select * from music where user_id = 1 limit 2", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -2072,9 +2018,7 @@ Gen4 plan same as above "FieldQuery": "select count(*) from music where 1 != 1", "Query": "select count(*) from music where user_id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } ] @@ -2272,9 +2216,7 @@ Gen4 plan same as above "FieldQuery": "select (select u.id from `user` as u where 1 != 1), a.id from `user` as a where 1 != 1", "Query": "select (select u.id from `user` as u where u.id = 1), a.id from `user` as a where a.id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } } @@ -2291,9 +2233,7 @@ Gen4 plan same as above "FieldQuery": "select (select u.id from `user` as u where 1 != 1), a.id from `user` as a where 1 != 1", "Query": "select (select u.id from `user` as u where u.id = 1), a.id from `user` as a where a.id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } } @@ -2844,9 +2784,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_id = 3 and user_id \u003c :user_id", "Table": "user_extra", - "Values": [ - "INT64(3)" - ], + "Values": "INT64(3)", "Vindex": "user_index" } ] @@ -2889,9 +2827,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_id = 3 and user_id \u003c :user_id", "Table": "user_extra", - "Values": [ - "INT64(3)" - ], + "Values": "INT64(3)", "Vindex": "user_index" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt index 556efbfb993..d0e93ebb337 100644 --- a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt @@ -924,9 +924,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where `user`.id = :x_id", "Table": "`user`", - "Values": [ - ":x_id" - ], + "Values": ":x_id", "Vindex": "user_index" } ] @@ -966,9 +964,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where `user`.id = :x_id", "Table": "`user`", - "Values": [ - ":x_id" - ], + "Values": ":x_id", "Vindex": "user_index" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt index b2047028579..853485f7675 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt @@ -13,9 +13,7 @@ "FieldQuery": "select c_discount, c_last, c_credit, w_tax from customer1 as c join warehouse1 as w on c_w_id = w_id where 1 != 1", "Query": "select c_discount, c_last, c_credit, w_tax from customer1 as c join warehouse1 as w on c_w_id = w_id where w_id = 1 and c_d_id = 15 and c_id = 10", "Table": "customer1, warehouse1", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "hash" } } @@ -32,9 +30,7 @@ "FieldQuery": "select c_discount, c_last, c_credit, w_tax from customer1 as c, warehouse1 as w where 1 != 1", "Query": "select c_discount, c_last, c_credit, w_tax from customer1 as c, warehouse1 as w where c_d_id = 15 and c_id = 10 and w_id = 1 and c_w_id = w_id", "Table": "customer1, warehouse1", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "hash" } } @@ -54,9 +50,7 @@ "FieldQuery": "select d_next_o_id, d_tax from district1 where 1 != 1", "Query": "select d_next_o_id, d_tax from district1 where d_w_id = 15 and d_id = 95 for update", "Table": "district1", - "Values": [ - 15 - ], + "Values": 15, "Vindex": "hash" } } @@ -73,9 +67,7 @@ "FieldQuery": "select d_next_o_id, d_tax from district1 where 1 != 1", "Query": "select d_next_o_id, d_tax from district1 where d_w_id = 15 and d_id = 95 for update", "Table": "district1", - "Values": [ - "INT64(15)" - ], + "Values": "INT64(15)", "Vindex": "hash" } } @@ -159,9 +151,7 @@ Gen4 plan same as above "FieldQuery": "select i_price, i_name, i_data from item1 where 1 != 1", "Query": "select i_price, i_name, i_data from item1 where i_id = 9654", "Table": "item1", - "Values": [ - 9654 - ], + "Values": 9654, "Vindex": "hash" } } @@ -178,9 +168,7 @@ Gen4 plan same as above "FieldQuery": "select i_price, i_name, i_data from item1 where 1 != 1", "Query": "select i_price, i_name, i_data from item1 where i_id = 9654", "Table": "item1", - "Values": [ - "INT64(9654)" - ], + "Values": "INT64(9654)", "Vindex": "hash" } } @@ -200,9 +188,7 @@ Gen4 plan same as above "FieldQuery": "select s_quantity, s_data, s_dist_01 as s_dist from stock1 where 1 != 1", "Query": "select s_quantity, s_data, s_dist_01 as s_dist from stock1 where s_i_id = 2198 and s_w_id = 89 for update", "Table": "stock1", - "Values": [ - 89 - ], + "Values": 89, "Vindex": "hash" } } @@ -219,9 +205,7 @@ Gen4 plan same as above "FieldQuery": "select s_quantity, s_data, s_dist_01 as s_dist from stock1 where 1 != 1", "Query": "select s_quantity, s_data, s_dist_01 as s_dist from stock1 where s_i_id = 2198 and s_w_id = 89 for update", "Table": "stock1", - "Values": [ - "INT64(89)" - ], + "Values": "INT64(89)", "Vindex": "hash" } } @@ -309,9 +293,7 @@ Gen4 plan same as above "FieldQuery": "select w_street_1, w_street_2, w_city, w_state, w_zip, w_name from warehouse1 where 1 != 1", "Query": "select w_street_1, w_street_2, w_city, w_state, w_zip, w_name from warehouse1 where w_id = 998", "Table": "warehouse1", - "Values": [ - 998 - ], + "Values": 998, "Vindex": "hash" } } @@ -328,9 +310,7 @@ Gen4 plan same as above "FieldQuery": "select w_street_1, w_street_2, w_city, w_state, w_zip, w_name from warehouse1 where 1 != 1", "Query": "select w_street_1, w_street_2, w_city, w_state, w_zip, w_name from warehouse1 where w_id = 998", "Table": "warehouse1", - "Values": [ - "INT64(998)" - ], + "Values": "INT64(998)", "Vindex": "hash" } } @@ -374,9 +354,7 @@ Gen4 plan same as above "FieldQuery": "select d_street_1, d_street_2, d_city, d_state, d_zip, d_name from district1 where 1 != 1", "Query": "select d_street_1, d_street_2, d_city, d_state, d_zip, d_name from district1 where d_w_id = 896 and d_id = 9", "Table": "district1", - "Values": [ - 896 - ], + "Values": 896, "Vindex": "hash" } } @@ -393,9 +371,7 @@ Gen4 plan same as above "FieldQuery": "select d_street_1, d_street_2, d_city, d_state, d_zip, d_name from district1 where 1 != 1", "Query": "select d_street_1, d_street_2, d_city, d_state, d_zip, d_name from district1 where d_w_id = 896 and d_id = 9", "Table": "district1", - "Values": [ - "INT64(896)" - ], + "Values": "INT64(896)", "Vindex": "hash" } } @@ -415,9 +391,7 @@ Gen4 plan same as above "FieldQuery": "select count(c_id) as namecnt from customer1 where 1 != 1", "Query": "select count(c_id) as namecnt from customer1 where c_w_id = 5 and c_d_id = 1 and c_last = 'last'", "Table": "customer1", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "hash" } } @@ -434,9 +408,7 @@ Gen4 plan same as above "FieldQuery": "select count(c_id) as namecnt from customer1 where 1 != 1", "Query": "select count(c_id) as namecnt from customer1 where c_w_id = 5 and c_d_id = 1 and c_last = 'last'", "Table": "customer1", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "hash" } } @@ -456,9 +428,7 @@ Gen4 plan same as above "FieldQuery": "select c_id from customer1 where 1 != 1", "Query": "select c_id from customer1 where c_w_id = 8 and c_d_id = 5 and c_last = 'item_last' order by c_first asc", "Table": "customer1", - "Values": [ - 8 - ], + "Values": 8, "Vindex": "hash" } } @@ -475,9 +445,7 @@ Gen4 plan same as above "FieldQuery": "select c_id from customer1 where 1 != 1", "Query": "select c_id from customer1 where c_w_id = 8 and c_d_id = 5 and c_last = 'item_last' order by c_first asc", "Table": "customer1", - "Values": [ - "INT64(8)" - ], + "Values": "INT64(8)", "Vindex": "hash" } } @@ -497,9 +465,7 @@ Gen4 plan same as above "FieldQuery": "select c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since from customer1 where 1 != 1", "Query": "select c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since from customer1 where c_w_id = 8965 and c_d_id = 1 and c_id = 9 for update", "Table": "customer1", - "Values": [ - 8965 - ], + "Values": 8965, "Vindex": "hash" } } @@ -516,9 +482,7 @@ Gen4 plan same as above "FieldQuery": "select c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since from customer1 where 1 != 1", "Query": "select c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since from customer1 where c_w_id = 8965 and c_d_id = 1 and c_id = 9 for update", "Table": "customer1", - "Values": [ - "INT64(8965)" - ], + "Values": "INT64(8965)", "Vindex": "hash" } } @@ -538,9 +502,7 @@ Gen4 plan same as above "FieldQuery": "select c_data from customer1 where 1 != 1", "Query": "select c_data from customer1 where c_w_id = 32 and c_d_id = 68 and c_id = 5", "Table": "customer1", - "Values": [ - 32 - ], + "Values": 32, "Vindex": "hash" } } @@ -557,9 +519,7 @@ Gen4 plan same as above "FieldQuery": "select c_data from customer1 where 1 != 1", "Query": "select c_data from customer1 where c_w_id = 32 and c_d_id = 68 and c_id = 5", "Table": "customer1", - "Values": [ - "INT64(32)" - ], + "Values": "INT64(32)", "Vindex": "hash" } } @@ -647,9 +607,7 @@ Gen4 plan same as above "FieldQuery": "select count(c_id) as namecnt from customer1 where 1 != 1", "Query": "select count(c_id) as namecnt from customer1 where c_w_id = 870 and c_d_id = 780 and c_last = 'last'", "Table": "customer1", - "Values": [ - 870 - ], + "Values": 870, "Vindex": "hash" } } @@ -666,9 +624,7 @@ Gen4 plan same as above "FieldQuery": "select count(c_id) as namecnt from customer1 where 1 != 1", "Query": "select count(c_id) as namecnt from customer1 where c_w_id = 870 and c_d_id = 780 and c_last = 'last'", "Table": "customer1", - "Values": [ - "INT64(870)" - ], + "Values": "INT64(870)", "Vindex": "hash" } } @@ -688,9 +644,7 @@ Gen4 plan same as above "FieldQuery": "select c_balance, c_first, c_middle, c_id from customer1 where 1 != 1", "Query": "select c_balance, c_first, c_middle, c_id from customer1 where c_w_id = 840 and c_d_id = 1 and c_last = 'test' order by c_first asc", "Table": "customer1", - "Values": [ - 840 - ], + "Values": 840, "Vindex": "hash" } } @@ -707,9 +661,7 @@ Gen4 plan same as above "FieldQuery": "select c_balance, c_first, c_middle, c_id from customer1 where 1 != 1", "Query": "select c_balance, c_first, c_middle, c_id from customer1 where c_w_id = 840 and c_d_id = 1 and c_last = 'test' order by c_first asc", "Table": "customer1", - "Values": [ - "INT64(840)" - ], + "Values": "INT64(840)", "Vindex": "hash" } } @@ -729,9 +681,7 @@ Gen4 plan same as above "FieldQuery": "select c_balance, c_first, c_middle, c_last from customer1 where 1 != 1", "Query": "select c_balance, c_first, c_middle, c_last from customer1 where c_w_id = 15 and c_d_id = 5169 and c_id = 1", "Table": "customer1", - "Values": [ - 15 - ], + "Values": 15, "Vindex": "hash" } } @@ -748,9 +698,7 @@ Gen4 plan same as above "FieldQuery": "select c_balance, c_first, c_middle, c_last from customer1 where 1 != 1", "Query": "select c_balance, c_first, c_middle, c_last from customer1 where c_w_id = 15 and c_d_id = 5169 and c_id = 1", "Table": "customer1", - "Values": [ - "INT64(15)" - ], + "Values": "INT64(15)", "Vindex": "hash" } } @@ -770,9 +718,7 @@ Gen4 plan same as above "FieldQuery": "select o_id, o_carrier_id, o_entry_d from orders1 where 1 != 1", "Query": "select o_id, o_carrier_id, o_entry_d from orders1 where o_w_id = 9894 and o_d_id = 3 and o_c_id = 159 order by o_id desc", "Table": "orders1", - "Values": [ - 9894 - ], + "Values": 9894, "Vindex": "hash" } } @@ -789,9 +735,7 @@ Gen4 plan same as above "FieldQuery": "select o_id, o_carrier_id, o_entry_d from orders1 where 1 != 1", "Query": "select o_id, o_carrier_id, o_entry_d from orders1 where o_w_id = 9894 and o_d_id = 3 and o_c_id = 159 order by o_id desc", "Table": "orders1", - "Values": [ - "INT64(9894)" - ], + "Values": "INT64(9894)", "Vindex": "hash" } } @@ -811,9 +755,7 @@ Gen4 plan same as above "FieldQuery": "select ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d from order_line1 where 1 != 1", "Query": "select ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d from order_line1 where ol_w_id = 92 and ol_d_id = 5 and ol_o_id = 1", "Table": "order_line1", - "Values": [ - 92 - ], + "Values": 92, "Vindex": "hash" } } @@ -830,9 +772,7 @@ Gen4 plan same as above "FieldQuery": "select ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d from order_line1 where 1 != 1", "Query": "select ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d from order_line1 where ol_w_id = 92 and ol_d_id = 5 and ol_o_id = 1", "Table": "order_line1", - "Values": [ - "INT64(92)" - ], + "Values": "INT64(92)", "Vindex": "hash" } } @@ -852,9 +792,7 @@ Gen4 plan same as above "FieldQuery": "select no_o_id from new_orders1 where 1 != 1", "Query": "select no_o_id from new_orders1 where no_d_id = 689 and no_w_id = 15 order by no_o_id asc limit 1 for update", "Table": "new_orders1", - "Values": [ - 15 - ], + "Values": 15, "Vindex": "hash" } } @@ -871,9 +809,7 @@ Gen4 plan same as above "FieldQuery": "select no_o_id from new_orders1 where 1 != 1", "Query": "select no_o_id from new_orders1 where no_d_id = 689 and no_w_id = 15 order by no_o_id asc limit 1 for update", "Table": "new_orders1", - "Values": [ - "INT64(15)" - ], + "Values": "INT64(15)", "Vindex": "hash" } } @@ -917,9 +853,7 @@ Gen4 plan same as above "FieldQuery": "select o_c_id from orders1 where 1 != 1", "Query": "select o_c_id from orders1 where o_id = 6 and o_d_id = 1983 and o_w_id = 894605", "Table": "orders1", - "Values": [ - 894605 - ], + "Values": 894605, "Vindex": "hash" } } @@ -936,9 +870,7 @@ Gen4 plan same as above "FieldQuery": "select o_c_id from orders1 where 1 != 1", "Query": "select o_c_id from orders1 where o_id = 6 and o_d_id = 1983 and o_w_id = 894605", "Table": "orders1", - "Values": [ - "INT64(894605)" - ], + "Values": "INT64(894605)", "Vindex": "hash" } } @@ -1006,9 +938,7 @@ Gen4 plan same as above "FieldQuery": "select SUM(ol_amount) as sm from order_line1 where 1 != 1", "Query": "select SUM(ol_amount) as sm from order_line1 where ol_o_id = 680 and ol_d_id = 201 and ol_w_id = 87", "Table": "order_line1", - "Values": [ - 87 - ], + "Values": 87, "Vindex": "hash" } } @@ -1025,9 +955,7 @@ Gen4 plan same as above "FieldQuery": "select SUM(ol_amount) as sm from order_line1 where 1 != 1", "Query": "select SUM(ol_amount) as sm from order_line1 where ol_o_id = 680 and ol_d_id = 201 and ol_w_id = 87", "Table": "order_line1", - "Values": [ - "INT64(87)" - ], + "Values": "INT64(87)", "Vindex": "hash" } } @@ -1071,9 +999,7 @@ Gen4 plan same as above "FieldQuery": "select d_next_o_id from district1 where 1 != 1", "Query": "select d_next_o_id from district1 where d_id = 6 and d_w_id = 21", "Table": "district1", - "Values": [ - 21 - ], + "Values": 21, "Vindex": "hash" } } @@ -1090,9 +1016,7 @@ Gen4 plan same as above "FieldQuery": "select d_next_o_id from district1 where 1 != 1", "Query": "select d_next_o_id from district1 where d_id = 6 and d_w_id = 21", "Table": "district1", - "Values": [ - "INT64(21)" - ], + "Values": "INT64(21)", "Vindex": "hash" } } @@ -1112,9 +1036,7 @@ Gen4 plan same as above "FieldQuery": "select COUNT(distinct s.s_i_id) from stock1 as s join order_line1 as ol on ol.ol_w_id = s.s_w_id and ol.ol_i_id = s.s_i_id where 1 != 1", "Query": "select COUNT(distinct s.s_i_id) from stock1 as s join order_line1 as ol on ol.ol_w_id = s.s_w_id and ol.ol_i_id = s.s_i_id where ol.ol_w_id = 12 and ol.ol_d_id = 1908 and ol.ol_o_id \u003c 30 and ol.ol_o_id \u003e= 15 and s.s_w_id = 12 and s.s_quantity \u003c 10", "Table": "stock1, order_line1", - "Values": [ - 12 - ], + "Values": 12, "Vindex": "hash" } } @@ -1131,9 +1053,7 @@ Gen4 plan same as above "FieldQuery": "select COUNT(distinct s.s_i_id) from stock1 as s, order_line1 as ol where 1 != 1", "Query": "select COUNT(distinct s.s_i_id) from stock1 as s, order_line1 as ol where s.s_w_id = 12 and s.s_quantity \u003c 10 and ol.ol_w_id = 12 and ol.ol_d_id = 1908 and ol.ol_o_id \u003c 30 and ol.ol_o_id \u003e= 15 and ol.ol_w_id = s.s_w_id and ol.ol_i_id = s.s_i_id", "Table": "order_line1, stock1", - "Values": [ - "INT64(12)" - ], + "Values": "INT64(12)", "Vindex": "hash" } } @@ -1153,9 +1073,7 @@ Gen4 plan same as above "FieldQuery": "select ol_i_id from order_line1 where 1 != 1", "Query": "select distinct ol_i_id from order_line1 where ol_w_id = 1 and ol_d_id = 156 and ol_o_id \u003c 500 and ol_o_id \u003e= 56", "Table": "order_line1", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "hash" } } @@ -1172,9 +1090,7 @@ Gen4 plan same as above "FieldQuery": "select ol_i_id from order_line1 where 1 != 1", "Query": "select distinct ol_i_id from order_line1 where ol_w_id = 1 and ol_d_id = 156 and ol_o_id \u003c 500 and ol_o_id \u003e= 56", "Table": "order_line1", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "hash" } } @@ -1194,9 +1110,7 @@ Gen4 plan same as above "FieldQuery": "select count(*) from stock1 where 1 != 1", "Query": "select count(*) from stock1 where s_w_id = 1 and s_i_id = 8 and s_quantity \u003c 1000", "Table": "stock1", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "hash" } } @@ -1213,9 +1127,7 @@ Gen4 plan same as above "FieldQuery": "select count(*) from stock1 where 1 != 1", "Query": "select count(*) from stock1 where s_w_id = 1 and s_i_id = 8 and s_quantity \u003c 1000", "Table": "stock1", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "hash" } } @@ -1261,9 +1173,7 @@ Gen4 plan same as above "FieldQuery": "select 1 from (select o_c_id, o_w_id, o_d_id, count(distinct o_w_id), o_id from orders1 where 1 != 1 group by o_c_id, o_d_id, o_w_id) as t where 1 != 1", "Query": "select 1 from (select o_c_id, o_w_id, o_d_id, count(distinct o_w_id), o_id from orders1 where o_w_id = 1 and o_id \u003e 2100 and o_id \u003c 11153 group by o_c_id, o_d_id, o_w_id having count(distinct o_id) \u003e 1 limit 1) as t where t.o_w_id = :o_o_w_id and t.o_d_id = :o_o_d_id and t.o_c_id = :o_o_c_id", "Table": "orders1", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "hash" } ] @@ -1284,9 +1194,7 @@ Gen4 plan same as above "FieldQuery": "select o.o_id, o.o_d_id from orders1 as o, (select o_c_id, o_w_id, o_d_id, count(distinct o_w_id), o_id from orders1 where 1 != 1) as t where 1 != 1", "Query": "select o.o_id, o.o_d_id from orders1 as o, (select o_c_id, o_w_id, o_d_id, count(distinct o_w_id), o_id from orders1 where o_w_id = 1 and o_id \u003e 2100 and o_id \u003c 11153) as t where t.o_w_id = o.o_w_id and t.o_d_id = o.o_d_id and t.o_c_id = o.o_c_id limit 1", "Table": "orders1", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "hash" } } diff --git a/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt b/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt index c992b6eda13..befead9ddde 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt @@ -177,9 +177,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "FieldQuery": "select total_revenue from revenue0 where 1 != 1", "Query": "select total_revenue from revenue0 where supplier_no = :s_suppkey and total_revenue = :__sq1", "Table": "revenue0", - "Values": [ - ":s_suppkey" - ], + "Values": ":s_suppkey", "Vindex": "hash" } ] @@ -306,9 +304,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "FieldQuery": "select p_brand, p_type, p_size, weight_string(p_brand), weight_string(p_type), weight_string(p_size) from part where 1 != 1", "Query": "select p_brand, p_type, p_size, weight_string(p_brand), weight_string(p_type), weight_string(p_size) from part where p_brand != 'Brand#45' and p_type not like 'MEDIUM POLISHED%' and p_size in (49, 14, 23, 45, 19, 3, 36, 9) and p_partkey = :ps_partkey", "Table": "part", - "Values": [ - ":ps_partkey" - ], + "Values": ":ps_partkey", "Vindex": "hash" } ] @@ -388,9 +384,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "OrderBy": "(3|6) DESC, (2|5) ASC", "Query": "select o_custkey, o_orderkey, o_orderdate, o_totalprice, weight_string(o_orderkey), weight_string(o_orderdate), weight_string(o_totalprice) from orders where :__sq_has_values1 = 1 and o_orderkey in ::__vals order by o_totalprice desc, o_orderdate asc", "Table": "orders", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "hash" }, { @@ -403,9 +397,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "FieldQuery": "select c_name, c_custkey, weight_string(c_name), weight_string(c_custkey) from customer where 1 != 1", "Query": "select c_name, c_custkey, weight_string(c_name), weight_string(c_custkey) from customer where c_custkey = :o_custkey", "Table": "customer", - "Values": [ - ":o_custkey" - ], + "Values": ":o_custkey", "Vindex": "hash" } ] @@ -420,9 +412,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "FieldQuery": "select sum(l_quantity) from lineitem where 1 != 1", "Query": "select sum(l_quantity) from lineitem where l_orderkey = :o_orderkey", "Table": "lineitem", - "Values": [ - ":o_orderkey" - ], + "Values": ":o_orderkey", "Vindex": "lineitem_map" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/union_cases.txt b/go/vt/vtgate/planbuilder/testdata/union_cases.txt index 9625730f272..37dd70e0b4e 100644 --- a/go/vt/vtgate/planbuilder/testdata/union_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/union_cases.txt @@ -94,9 +94,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -109,9 +107,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5", "Table": "`user`", - "Values": [ - 5 - ], + "Values": 5, "Vindex": "user_index" } ] @@ -133,9 +129,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -148,9 +142,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1", "Query": "select id from `user` where id = 5", "Table": "`user`", - "Values": [ - "INT64(5)" - ], + "Values": "INT64(5)", "Vindex": "user_index" } ] @@ -334,9 +326,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1 union select id from `user` where 1 != 1", "Query": "select id from `user` where id = 1 union select id from `user` where id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" }, { @@ -369,9 +359,7 @@ Gen4 plan same as above "FieldQuery": "select id from `user` where 1 != 1 union select id from `user` where 1 != 1", "Query": "select id from `user` where id = 1 union select id from `user` where id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" }, { @@ -773,9 +761,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select * from music where 1 != 1", "Query": "select * from music where id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "music_user_map" }, { @@ -788,9 +774,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select * from `user` where 1 != 1", "Query": "select * from `user` where id = 1", "Table": "`user`", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "user_index" } ] @@ -817,9 +801,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select * from music where 1 != 1", "Query": "select distinct * from music where id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "music_user_map" }, { @@ -832,9 +814,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select * from `user` where 1 != 1", "Query": "select distinct * from `user` where id = 1", "Table": "`user`", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "user_index" } ] @@ -864,9 +844,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select 1 from music where 1 != 1", "Query": "select 1 from music where id = 1", "Table": "music", - "Values": [ - 1 - ], + "Values": 1, "Vindex": "music_user_map" }, { @@ -879,9 +857,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select 1 from music where 1 != 1", "Query": "select 1 from music where id = 2", "Table": "music", - "Values": [ - 2 - ], + "Values": 2, "Vindex": "music_user_map" } ] @@ -908,9 +884,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select 1 from music where 1 != 1", "Query": "select distinct 1 from music where id = 1", "Table": "music", - "Values": [ - "INT64(1)" - ], + "Values": "INT64(1)", "Vindex": "music_user_map" }, { @@ -923,9 +897,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "FieldQuery": "select 1 from music where 1 != 1", "Query": "select distinct 1 from music where id = 2", "Table": "music", - "Values": [ - "INT64(2)" - ], + "Values": "INT64(2)", "Vindex": "music_user_map" } ] diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt index 9caafc33da1..b6a8d783940 100644 --- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt @@ -545,9 +545,7 @@ Gen4 error: expr cannot be converted, not supported: *sqlparser.FuncExpr "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` having count(id) = 10 and `name` = 'a'", "Table": "`user`", - "Values": [ - "a" - ], + "Values": "a", "Vindex": "name_user_map" } } diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt index 63417b3d8e8..d3e3e6b02c6 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt @@ -71,9 +71,7 @@ "FieldQuery": "select u.id as uid from `user` as u where 1 != 1", "Query": "select u.id as uid from `user` as u where u.id = :e_id", "Table": "`user`", - "Values": [ - ":e_id" - ], + "Values": ":e_id", "Vindex": "user_index" } ] @@ -153,9 +151,7 @@ "FieldQuery": "select u.id as uid from `user` as u where 1 != 1", "Query": "select u.id as uid from `user` as u where u.id = :e_id", "Table": "`user`", - "Values": [ - ":e_id" - ], + "Values": ":e_id", "Vindex": "user_index" } ] @@ -582,9 +578,7 @@ "FieldQuery": "select 1 from `user` as u3 where 1 != 1", "Query": "select 1 from `user` as u3 where u3.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" } ] @@ -675,9 +669,7 @@ "FieldQuery": "select 1 from `user` as u3 where 1 != 1", "Query": "select 1 from `user` as u3 where u3.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" } ] @@ -728,9 +720,7 @@ "FieldQuery": "select 1 from `user` as u2 where 1 != 1", "Query": "select 1 from `user` as u2 where u2.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" }, { @@ -743,9 +733,7 @@ "FieldQuery": "select 1 from `user` as u3 where 1 != 1", "Query": "select 1 from `user` as u3 where u3.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" } ] @@ -797,9 +785,7 @@ "FieldQuery": "select 1 from `user` as u2 where 1 != 1", "Query": "select 1 from `user` as u2 where u2.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" } ] @@ -814,9 +800,7 @@ "FieldQuery": "select 1 from `user` as u3 where 1 != 1", "Query": "select 1 from `user` as u3 where u3.id = :u1_col", "Table": "`user`", - "Values": [ - ":u1_col" - ], + "Values": ":u1_col", "Vindex": "user_index" } ] @@ -896,9 +880,7 @@ "FieldQuery": "select `weird``name`.a from `weird``name` where 1 != 1", "Query": "select `weird``name`.a from `weird``name` where `weird``name`.`a``b*c` = :unsharded_id", "Table": "`weird``name`", - "Values": [ - ":unsharded_id" - ], + "Values": ":unsharded_id", "Vindex": "user_index" } ] @@ -978,9 +960,7 @@ "FieldQuery": "select 1 from `weird``name` where 1 != 1", "Query": "select 1 from `weird``name` where `weird``name`.`a``b*c` = :unsharded_id", "Table": "`weird``name`", - "Values": [ - ":unsharded_id" - ], + "Values": ":unsharded_id", "Vindex": "user_index" } ] @@ -1139,9 +1119,7 @@ "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - "::__sq1" - ], + "Values": "::__sq1", "Vindex": "user_index" } ] @@ -1208,9 +1186,7 @@ "FieldQuery": "select 1 from `user` where 1 != 1", "Query": "select 1 from `user` where :__sq_has_values1 = 1 and id in ::__vals", "Table": "`user`", - "Values": [ - ":__sq1" - ], + "Values": ":__sq1", "Vindex": "user_index" } ]