From 9762111d58d235443d2fdd910853724710f929d0 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Sat, 28 Mar 2020 10:25:19 +0100 Subject: [PATCH 01/10] Added new PlanDescription struct Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/plan_description.go | 49 +++++++++++++++ go/vt/vtgate/engine/plan_description_test.go | 63 ++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 go/vt/vtgate/engine/plan_description.go create mode 100644 go/vt/vtgate/engine/plan_description_test.go diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go new file mode 100644 index 00000000000..679a5b1ea1e --- /dev/null +++ b/go/vt/vtgate/engine/plan_description.go @@ -0,0 +1,49 @@ +/* +Copyright 2020 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 ( + topodatapb "vitess.io/vitess/go/vt/proto/topodata" +) + +// PlanDescription is used to create a serializable representation of the Primitive tree +type PlanDescription struct { + OperatorType string + OpCode string + Keyspace string + Destination string + TabletType topodatapb.TabletType + Other map[string]string + Inputs []PlanDescription +} + +//PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree +func PrimitiveToPlanDescription(in Primitive) PlanDescription { + var this PlanDescription + + switch p := in.(type) { + case *Route: + this = PlanDescription{ + OperatorType: "Route", + OpCode: p.RouteType(), + Keyspace: p.Keyspace.Name, + Destination: p.TargetDestination.String(), + TabletType: p.TargetTabletType, + } + } + return this +} diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go new file mode 100644 index 00000000000..2570328eba4 --- /dev/null +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -0,0 +1,63 @@ +/* +Copyright 2020 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" + "testing" + + "vitess.io/vitess/go/sqltypes" + + "github.com/google/go-cmp/cmp" + "vitess.io/vitess/go/jsonutil" + "vitess.io/vitess/go/vt/key" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/vt/vtgate/vindexes" +) + +func TestCreatePlanDescription(t *testing.T) { + del := &Route{ + Opcode: SelectScatter, + Keyspace: &vindexes.Keyspace{Name: "ks"}, + TargetDestination: key.DestinationAllShards{}, + TargetTabletType: topodatapb.TabletType_MASTER, + Query: "select all the things", + TableName: "tableName", + FieldQuery: "more query", + Vindex: &vindexes.Null{}, + Values: []sqltypes.PlanValue{}, + OrderBy: []OrderbyParams{}, + } + + planDescription := PrimitiveToPlanDescription(del) + + expected := PlanDescription{ + OperatorType: "Route", + OpCode: "SelectScatter", + Keyspace: "ks", + Destination: "DestinationAllShards()", + TabletType: topodatapb.TabletType_MASTER, + } + + if diff := cmp.Diff(planDescription, expected); diff != "" { + t.Errorf(diff) + bytes, _ := jsonutil.MarshalNoEscape(expected) + fmt.Println(string(bytes)) + fmt.Printf("%v\n", expected) + } + +} From bb062fb1e139f48448aa4c73972b632820b9444b Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Mon, 30 Mar 2020 17:09:43 +0200 Subject: [PATCH 02/10] Added Description to the Primitive interface Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/delete.go | 4 ++ go/vt/vtgate/engine/fake_primitive_test.go | 4 ++ go/vt/vtgate/engine/insert.go | 4 ++ go/vt/vtgate/engine/join.go | 4 ++ go/vt/vtgate/engine/limit.go | 22 ++++++ go/vt/vtgate/engine/memory_sort.go | 4 ++ go/vt/vtgate/engine/merge_sort.go | 4 ++ go/vt/vtgate/engine/ordered_aggregate.go | 7 ++ go/vt/vtgate/engine/plan_description.go | 29 +++----- go/vt/vtgate/engine/plan_description_test.go | 76 +++++++++++++++++--- go/vt/vtgate/engine/primitive.go | 4 ++ go/vt/vtgate/engine/pullout_subquery.go | 4 ++ go/vt/vtgate/engine/route.go | 17 +++++ go/vt/vtgate/engine/subquery.go | 4 ++ go/vt/vtgate/engine/update.go | 4 ++ go/vt/vtgate/engine/vindex_func.go | 4 ++ go/vt/vtgate/planbuilder/plan_test.go | 5 ++ 17 files changed, 170 insertions(+), 30 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 409ce0d5d97..c148b8dae0f 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -234,3 +234,7 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] res, errs := vcursor.ExecuteMultiShard(rss, queries, true /* rollbackOnError */, autocommit) return res, vterrors.Aggregate(errs) } + +func (del *Delete) description() PlanDescription { + return PlanDescription{OperatorType: "delete not implemented"} +} diff --git a/go/vt/vtgate/engine/fake_primitive_test.go b/go/vt/vtgate/engine/fake_primitive_test.go index 2c0641a9791..419d3c269b0 100644 --- a/go/vt/vtgate/engine/fake_primitive_test.go +++ b/go/vt/vtgate/engine/fake_primitive_test.go @@ -137,3 +137,7 @@ func wrapStreamExecute(prim Primitive, vcursor VCursor, bindVars map[string]*que } return result, err } + +func (f *fakePrimitive) description() PlanDescription { + return PlanDescription{OperatorType: "fake - not implemented"} +} diff --git a/go/vt/vtgate/engine/insert.go b/go/vt/vtgate/engine/insert.go index e08d5398ea2..12813a0a986 100644 --- a/go/vt/vtgate/engine/insert.go +++ b/go/vt/vtgate/engine/insert.go @@ -607,3 +607,7 @@ func (ins *Insert) processUnowned(vcursor VCursor, vindexColumnsKeys [][]sqltype func insertVarName(col sqlparser.ColIdent, rowNum int) string { return "_" + col.CompliantName() + strconv.Itoa(rowNum) } + +func (ins *Insert) description() PlanDescription { + return PlanDescription{OperatorType: "insert - not implemented"} +} diff --git a/go/vt/vtgate/engine/join.go b/go/vt/vtgate/engine/join.go index e5779866056..06c72fd154f 100644 --- a/go/vt/vtgate/engine/join.go +++ b/go/vt/vtgate/engine/join.go @@ -254,3 +254,7 @@ func combineVars(bv1, bv2 map[string]*querypb.BindVariable) map[string]*querypb. } return out } + +func (jn *Join) description() PlanDescription { + return PlanDescription{OperatorType: "join - not implemented"} +} diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index 410a5af624d..f0e0b71e793 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -200,3 +200,25 @@ func (l *Limit) fetchOffset(bindVars map[string]*querypb.BindVariable) (int, err } return offset, nil } + +func (l *Limit) description() PlanDescription { + // TODO: There's got to be a better way + count, err := l.Count.MarshalJSON() + if err != nil { + count = []byte("?") + } + offset, err := l.Offset.MarshalJSON() + if err != nil { + offset = []byte("?") + } + + other := map[string]string{ + "Count": string(count), + "Offset": string(offset), + } + + return PlanDescription{ + OperatorType: "Limit", + Other: other, + } +} diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index f426eb2039b..5c88672b814 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -184,6 +184,10 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int return count, nil } +func (ms *MemorySort) description() PlanDescription { + return PlanDescription{OperatorType: "memorysort - not implemented"} +} + // sortHeap is sorted based on the orderBy params. // Implementation is similar to scatterHeap type sortHeap struct { diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index b95190cc7e8..8d46aa0af27 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -155,6 +155,10 @@ func (ms *MergeSort) StreamExecute(vcursor VCursor, bindVars map[string]*querypb return nil } +func (ms *MergeSort) description() PlanDescription { + return PlanDescription{OperatorType: "mergesort - not implemented"} +} + // streamHandle is the rendez-vous point between each stream and the merge-sorter. // The fields channel is used by the stream to transmit the field info, which // is the first packet. Following this, the stream sends each row to the row diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index 0cf008afb73..08ffd372f19 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -393,3 +393,10 @@ func createEmptyValueFor(opcode AggregateOpcode) (sqltypes.Value, error) { } return sqltypes.NULL, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "unknown aggregation %v", opcode) } + +func (oa *OrderedAggregate) description() PlanDescription { + return PlanDescription{ + OperatorType: "OrderedAggregation not implemented", + Other: nil, + } +} diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index 679a5b1ea1e..ae7927b12fb 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -16,34 +16,25 @@ limitations under the License. package engine -import ( - topodatapb "vitess.io/vitess/go/vt/proto/topodata" -) - // PlanDescription is used to create a serializable representation of the Primitive tree type PlanDescription struct { OperatorType string - OpCode string - Keyspace string - Destination string - TabletType topodatapb.TabletType + Variant string Other map[string]string Inputs []PlanDescription } //PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree func PrimitiveToPlanDescription(in Primitive) PlanDescription { - var this PlanDescription - - switch p := in.(type) { - case *Route: - this = PlanDescription{ - OperatorType: "Route", - OpCode: p.RouteType(), - Keyspace: p.Keyspace.Name, - Destination: p.TargetDestination.String(), - TabletType: p.TargetTabletType, - } + this := in.description() + + for _, input := range in.Inputs() { + this.Inputs = append(this.Inputs, PrimitiveToPlanDescription(input)) } + + if len(in.Inputs()) == 0 { + this.Inputs = []PlanDescription{} + } + return this } diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 2570328eba4..46c5c52690f 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -17,20 +17,47 @@ limitations under the License. package engine import ( + "encoding/json" "fmt" "testing" "vitess.io/vitess/go/sqltypes" "github.com/google/go-cmp/cmp" - "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/vtgate/vindexes" ) -func TestCreatePlanDescription(t *testing.T) { - del := &Route{ +func TestCreateRoutePlanDescription(t *testing.T) { + route := createRoute() + + planDescription := PrimitiveToPlanDescription(route) + + expected := PlanDescription{ + OperatorType: "Route", + Variant: "SelectScatter", + Other: map[string]string{ + "Query": route.Query, + "TableName": route.TableName, + "Keyspace": "ks", + "Destination": "DestinationAllShards()", + "TabletType": topodatapb.TabletType_MASTER.String(), + }, + Inputs: []PlanDescription{}, + } + + if diff := cmp.Diff(planDescription, expected); diff != "" { + t.Errorf(diff) + bytes, _ := json.MarshalIndent(expected, "", " ") + fmt.Println(string(bytes)) + fmt.Printf("%v\n", expected) + } + +} + +func createRoute() *Route { + return &Route{ Opcode: SelectScatter, Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, @@ -42,22 +69,49 @@ func TestCreatePlanDescription(t *testing.T) { Values: []sqltypes.PlanValue{}, OrderBy: []OrderbyParams{}, } +} + +func TestPlanDescriptionWithInputs(t *testing.T) { + route := createRoute() + routeDescr := getDescriptionFor(route) + limit := &Limit{ + Count: int64PlanValue(12), + Offset: int64PlanValue(4), + Input: route, + } - planDescription := PrimitiveToPlanDescription(del) + planDescription := PrimitiveToPlanDescription(limit) expected := PlanDescription{ - OperatorType: "Route", - OpCode: "SelectScatter", - Keyspace: "ks", - Destination: "DestinationAllShards()", - TabletType: topodatapb.TabletType_MASTER, + OperatorType: "Limit", + Other: map[string]string{ + "Count": "12", + "Offset": "4", + }, + Inputs: []PlanDescription{routeDescr}, } if diff := cmp.Diff(planDescription, expected); diff != "" { t.Errorf(diff) - bytes, _ := jsonutil.MarshalNoEscape(expected) + bytes, _ := json.MarshalIndent(expected, "", " ") + fmt.Println(string(bytes)) + bytes, _ = json.MarshalIndent(planDescription, "", " ") fmt.Println(string(bytes)) - fmt.Printf("%v\n", expected) } } + +func getDescriptionFor(route *Route) PlanDescription { + return PlanDescription{ + OperatorType: "Route", + Variant: routeName[route.Opcode], + Other: map[string]string{ + "Query": route.Query, + "TableName": route.TableName, + "Keyspace": "ks", + "Destination": "DestinationAllShards()", + "TabletType": topodatapb.TabletType_MASTER.String(), + }, + Inputs: []PlanDescription{}, + } +} diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go index 1ee2389b048..87450f6b62b 100644 --- a/go/vt/vtgate/engine/primitive.go +++ b/go/vt/vtgate/engine/primitive.go @@ -166,6 +166,10 @@ type Primitive interface { // The inputs to this Primitive Inputs() []Primitive + + // description is the description, sans the inputs, of this Primitive. + // to get the plan description with all children, use PrimitiveToPlanDescription() + description() PlanDescription } type noInputs struct{} diff --git a/go/vt/vtgate/engine/pullout_subquery.go b/go/vt/vtgate/engine/pullout_subquery.go index ade790599ac..7d3b00d915f 100644 --- a/go/vt/vtgate/engine/pullout_subquery.go +++ b/go/vt/vtgate/engine/pullout_subquery.go @@ -153,6 +153,10 @@ func (ps *PulloutSubquery) execSubquery(vcursor VCursor, bindVars map[string]*qu return combinedVars, nil } +func (ps *PulloutSubquery) description() PlanDescription { + return PlanDescription{OperatorType: "pullout subquery not implemented"} +} + // PulloutOpcode is a number representing the opcode // for the PulloutSubquery primitive. type PulloutOpcode int diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index d1d78a9bc13..d5f72186481 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -555,3 +555,20 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) } return shardVars } + +func (route *Route) description() PlanDescription { + other := map[string]string{ + "Query": route.Query, + "TableName": route.TableName, + "Keyspace": route.Keyspace.Name, + "TabletType": route.TargetTabletType.String(), + } + if route.TargetDestination != nil { + other["Destination"] = route.TargetDestination.String() + } + return PlanDescription{ + OperatorType: "Route", + Variant: routeName[route.Opcode], + Other: other, + } +} diff --git a/go/vt/vtgate/engine/subquery.go b/go/vt/vtgate/engine/subquery.go index fc37cd9b3ef..9ef181fa45f 100644 --- a/go/vt/vtgate/engine/subquery.go +++ b/go/vt/vtgate/engine/subquery.go @@ -102,3 +102,7 @@ func (sq *Subquery) buildFields(inner *sqltypes.Result) []*querypb.Field { } return fields } + +func (sq *Subquery) description() PlanDescription { + return PlanDescription{OperatorType: "subquery - not implemented"} +} diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index 684fe65d7d3..f1f16d0386c 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -263,3 +263,7 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] result, errs := vcursor.ExecuteMultiShard(rss, queries, true /* rollbackOnError */, autocommit) return result, vterrors.Aggregate(errs) } + +func (upd *Update) description() PlanDescription { + return PlanDescription{OperatorType: "update - not implemented"} +} diff --git a/go/vt/vtgate/engine/vindex_func.go b/go/vt/vtgate/engine/vindex_func.go index bc1aaf61dad..6b10c97e92e 100644 --- a/go/vt/vtgate/engine/vindex_func.go +++ b/go/vt/vtgate/engine/vindex_func.go @@ -193,3 +193,7 @@ func (vf *VindexFunc) buildRow(id sqltypes.Value, ksid []byte, kr *topodatapb.Ke } return row } + +func (vf *VindexFunc) description() PlanDescription { + return PlanDescription{OperatorType: "vindexfunc - not implemented"} +} diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index a73ed6c8c88..aa5da5fd81d 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -299,6 +299,11 @@ func getPlanOrErrorOutput(err error, plan *engine.Plan) string { if err != nil { return err.Error() } + + descr := engine.PrimitiveToPlanDescription(plan.Instructions) + sss, _ := json.MarshalIndent(descr, "", " ") + fmt.Println(string(sss)) + bout, _ := json.MarshalIndent(testPlan{ Original: plan.Original, Instructions: plan.Instructions, From 2910261abfc8466779a0ce5630208ae57c61ff35 Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Tue, 31 Mar 2020 15:47:35 +0200 Subject: [PATCH 03/10] Added PlanDescriptions to some primitives Signed-off-by: Rohit Nayak --- go/vt/key/destination.go | 23 ++++++++++++++ go/vt/vtgate/engine/delete.go | 14 ++++++++- go/vt/vtgate/engine/dml.go | 11 +++++++ go/vt/vtgate/engine/insert.go | 21 ++++++++++++- go/vt/vtgate/engine/join.go | 13 +++++++- go/vt/vtgate/engine/limit.go | 7 +++-- go/vt/vtgate/engine/memory_sort.go | 31 ++++++++++++++++++- go/vt/vtgate/engine/merge_sort.go | 13 +++++++- go/vt/vtgate/engine/plan_description.go | 17 ++++++++-- go/vt/vtgate/engine/plan_description_test.go | 28 ++++++++--------- go/vt/vtgate/engine/route.go | 31 ++++++++++++------- go/vt/vtgate/engine/update.go | 22 ++++++++++++- .../planbuilder/testdata/select_cases.txt | 3 +- 13 files changed, 198 insertions(+), 36 deletions(-) diff --git a/go/vt/key/destination.go b/go/vt/key/destination.go index 66946504978..b554a1e2e3e 100644 --- a/go/vt/key/destination.go +++ b/go/vt/key/destination.go @@ -443,6 +443,29 @@ func (d DestinationAllShards) String() string { return "DestinationAllShards()" } +// +// DestinationVtGate +// + +// DestinationVtGate implies primitive executes entirely on vtgate +// It implements the Destination interface. +type DestinationVtGate struct{} + +// IsUnique is part of the Destination interface. +func (d DestinationVtGate) IsUnique() bool { + return true +} + +// Resolve is part of the Destination interface. +func (d DestinationVtGate) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error { + return nil +} + +// String is part of the Destination interface. +func (d DestinationVtGate) String() string { + return "DestinationVtGate()" +} + // // DestinationNone // diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index c148b8dae0f..9074f4bb618 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -20,6 +20,8 @@ import ( "fmt" "time" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" @@ -236,5 +238,15 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] } func (del *Delete) description() PlanDescription { - return PlanDescription{OperatorType: "delete not implemented"} + other := map[string]string{ + "Query": del.Query, + "TableName": del.GetTableName(), + } + return PlanDescription{ + OperatorType: "Delete", + Keyspace: del.Keyspace, + Variant: del.Opcode.String(), + TargetTabletType: topodatapb.TabletType_MASTER, + Other: other, + } } diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index a82e4290773..cdd32cc298a 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -82,3 +82,14 @@ const ( // e.g: UPDATE `keyspace[-]`.x1 SET foo=1 ByDestination ) + +var opcodeName = map[DMLOpcode]string{ + Unsharded: "Unsharded", + Equal: "Equal", + Scatter: "Scatter", + ByDestination: "ByDestination", +} + +func (op DMLOpcode) String() string { + return opcodeName[op] +} diff --git a/go/vt/vtgate/engine/insert.go b/go/vt/vtgate/engine/insert.go index 12813a0a986..829988c6e49 100644 --- a/go/vt/vtgate/engine/insert.go +++ b/go/vt/vtgate/engine/insert.go @@ -23,6 +23,8 @@ import ( "strings" "time" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" @@ -186,6 +188,11 @@ var insName = map[InsertOpcode]string{ InsertShardedIgnore: "InsertShardedIgnore", } +// String returns the opcode +func (code InsertOpcode) String() string { + return strings.ReplaceAll(insName[code], "Insert", "") +} + // MarshalJSON serializes the InsertOpcode as a JSON string. // It's used for testing and diagnostics. func (code InsertOpcode) MarshalJSON() ([]byte, error) { @@ -609,5 +616,17 @@ func insertVarName(col sqlparser.ColIdent, rowNum int) string { } func (ins *Insert) description() PlanDescription { - return PlanDescription{OperatorType: "insert - not implemented"} + other := map[string]string{ + "Query": ins.Query, + "TableName": ins.GetTableName(), + "MultiShardAutocommit": strconv.FormatBool(ins.MultiShardAutocommit), + "QueryTimeout": strconv.Itoa(ins.QueryTimeout), + } + return PlanDescription{ + OperatorType: "Insert", + Keyspace: ins.Keyspace, + Variant: ins.Opcode.String(), + TargetTabletType: topodatapb.TabletType_MASTER, + Other: other, + } } diff --git a/go/vt/vtgate/engine/join.go b/go/vt/vtgate/engine/join.go index 06c72fd154f..c81d6ae0ce5 100644 --- a/go/vt/vtgate/engine/join.go +++ b/go/vt/vtgate/engine/join.go @@ -18,8 +18,10 @@ package engine import ( "fmt" + "strings" "vitess.io/vitess/go/sqltypes" + "vitess.io/vitess/go/vt/key" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -256,5 +258,14 @@ func combineVars(bv1, bv2 map[string]*querypb.BindVariable) map[string]*querypb. } func (jn *Join) description() PlanDescription { - return PlanDescription{OperatorType: "join - not implemented"} + other := map[string]string{ + "TableName": jn.GetTableName(), + "JoinColumnIndexes": strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jn.Cols)), ","), "[]"), + } + return PlanDescription{ + OperatorType: "Join", + Variant: jn.Opcode.String(), + TargetDestination: key.DestinationVtGate{}, + Other: other, + } } diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index f0e0b71e793..18a369064c6 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -21,6 +21,8 @@ import ( "fmt" "io" + "vitess.io/vitess/go/vt/key" + "vitess.io/vitess/go/sqltypes" querypb "vitess.io/vitess/go/vt/proto/query" @@ -218,7 +220,8 @@ func (l *Limit) description() PlanDescription { } return PlanDescription{ - OperatorType: "Limit", - Other: other, + OperatorType: "Limit", + Other: other, + TargetDestination: key.DestinationVtGate{}, } } diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index 5c88672b814..d1768ba93c2 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -21,9 +21,11 @@ import ( "encoding/json" "fmt" "math" + "reflect" "sort" "vitess.io/vitess/go/sqltypes" + "vitess.io/vitess/go/vt/key" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -185,7 +187,34 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int } func (ms *MemorySort) description() PlanDescription { - return PlanDescription{OperatorType: "memorysort - not implemented"} + orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) + other := map[string]string{ + "UpperLimit": ms.UpperLimit.Value.String(), + "OrderBy": orderByIndexes, + } + return PlanDescription{ + OperatorType: "Sort", + Variant: "Memory", + TargetDestination: key.DestinationVtGate{}, + Other: other, + } +} + +func orderByParamsToString(i interface{}) string { + ob := i.(OrderbyParams) + return ob.String() +} + +func GenericJoin(input interface{}, f func(interface{}) string) string { + sl := reflect.ValueOf(input) + str := "" + for i := 0; i < sl.Len(); i++ { + if len(str) != 0 { + str += "," + } + str += f(sl.Index(i).Interface()) + } + return str } // sortHeap is sorted based on the orderBy params. diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index 8d46aa0af27..e139e76d9cd 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -20,6 +20,8 @@ import ( "container/heap" "io" + "vitess.io/vitess/go/vt/key" + "golang.org/x/net/context" "vitess.io/vitess/go/sqltypes" @@ -156,7 +158,16 @@ func (ms *MergeSort) StreamExecute(vcursor VCursor, bindVars map[string]*querypb } func (ms *MergeSort) description() PlanDescription { - return PlanDescription{OperatorType: "mergesort - not implemented"} + orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) + other := map[string]string{ + "OrderBy": orderByIndexes, + } + return PlanDescription{ + OperatorType: "Sort", + Variant: "Merge", + TargetDestination: key.DestinationVtGate{}, + Other: other, + } } // streamHandle is the rendez-vous point between each stream and the merge-sorter. diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index ae7927b12fb..a7836300648 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -16,12 +16,25 @@ limitations under the License. package engine +import ( + "vitess.io/vitess/go/vt/key" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/vt/vtgate/vindexes" +) + // PlanDescription is used to create a serializable representation of the Primitive tree type PlanDescription struct { OperatorType string Variant string - Other map[string]string - Inputs []PlanDescription + // Keyspace specifies the keyspace to send the query to. + Keyspace *vindexes.Keyspace + // TargetDestination specifies an explicit target destination to send the query to. + TargetDestination key.Destination + // TargetTabletType specifies an explicit target destination tablet type + // this is only used in conjunction with TargetDestination + TargetTabletType topodatapb.TabletType + Other map[string]string + Inputs []PlanDescription } //PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 46c5c52690f..79932bd06e2 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -35,14 +35,14 @@ func TestCreateRoutePlanDescription(t *testing.T) { planDescription := PrimitiveToPlanDescription(route) expected := PlanDescription{ - OperatorType: "Route", - Variant: "SelectScatter", + OperatorType: "Route", + Variant: "SelectScatter", + Keyspace: &vindexes.Keyspace{Name: "ks"}, + TargetDestination: key.DestinationAllShards{}, + TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]string{ - "Query": route.Query, - "TableName": route.TableName, - "Keyspace": "ks", - "Destination": "DestinationAllShards()", - "TabletType": topodatapb.TabletType_MASTER.String(), + "Query": route.Query, + "TableName": route.TableName, }, Inputs: []PlanDescription{}, } @@ -103,14 +103,14 @@ func TestPlanDescriptionWithInputs(t *testing.T) { func getDescriptionFor(route *Route) PlanDescription { return PlanDescription{ - OperatorType: "Route", - Variant: routeName[route.Opcode], + OperatorType: "Route", + Variant: routeName[route.Opcode], + Keyspace: &vindexes.Keyspace{Name: "ks"}, + TargetDestination: key.DestinationAllShards{}, + TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]string{ - "Query": route.Query, - "TableName": route.TableName, - "Keyspace": "ks", - "Destination": "DestinationAllShards()", - "TabletType": topodatapb.TabletType_MASTER.String(), + "Query": route.Query, + "TableName": route.TableName, }, Inputs: []PlanDescription{}, } diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index d5f72186481..789f436ac99 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "sort" + "strconv" "time" "vitess.io/vitess/go/jsonutil" @@ -114,6 +115,16 @@ type OrderbyParams struct { Desc bool } +func (obp OrderbyParams) String() string { + val := strconv.Itoa(obp.Col) + if obp.Desc { + val += " DESC" + } else { + val += " ASC" + } + return val +} + // MarshalJSON serializes the Route into a JSON representation. // It's used for testing and diagnostics. func (route *Route) MarshalJSON() ([]byte, error) { @@ -144,7 +155,7 @@ func (route *Route) MarshalJSON() ([]byte, error) { TruncateColumnCount: route.TruncateColumnCount, QueryTimeout: route.QueryTimeout, ScatterErrorsAsWarnings: route.ScatterErrorsAsWarnings, - Table: route.TableName, + Table: route.TableName, } return jsonutil.MarshalNoEscape(marshalRoute) } @@ -558,17 +569,15 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) func (route *Route) description() PlanDescription { other := map[string]string{ - "Query": route.Query, - "TableName": route.TableName, - "Keyspace": route.Keyspace.Name, - "TabletType": route.TargetTabletType.String(), - } - if route.TargetDestination != nil { - other["Destination"] = route.TargetDestination.String() + "Query": route.Query, + "TableName": route.TableName, } return PlanDescription{ - OperatorType: "Route", - Variant: routeName[route.Opcode], - Other: other, + OperatorType: "Route", + Variant: routeName[route.Opcode], + Keyspace: route.Keyspace, + TargetDestination: route.TargetDestination, + TargetTabletType: route.TargetTabletType, + Other: other, } } diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index f1f16d0386c..5162de54fdb 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -20,6 +20,8 @@ import ( "fmt" "time" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" @@ -265,5 +267,23 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] } func (upd *Update) description() PlanDescription { - return PlanDescription{OperatorType: "update - not implemented"} + changedVindexes := "" + for vindex := range upd.ChangedVindexValues { + if len(changedVindexes) != 0 { + changedVindexes += "," + } + changedVindexes += vindex + } + other := map[string]string{ + "Query": upd.Query, + "TableName": upd.GetTableName(), + "Vindexes": changedVindexes, + } + return PlanDescription{ + OperatorType: "Update", + Keyspace: upd.Keyspace, + Variant: upd.Opcode.String(), + TargetTabletType: topodatapb.TabletType_MASTER, + Other: other, + } } diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index 8002a056fb4..682b235e150 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -841,7 +841,8 @@ "Name": "user", "Sharded": true }, - "Query": "select user0_.col as col0_ from user as user0_ where id = 1 order by user0_.col desc limit 2", + "Query": "select user0_.col as col0_ from user as user0_ where id = 1 + user0_.col desc limit 2", "FieldQuery": "select user0_.col as col0_ from user as user0_ where 1 != 1", "Vindex": "user_index", "Values": [ From 3576a2a2f69c3fb653c3d3765da907ebe8ba6980 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Tue, 31 Mar 2020 17:35:22 +0200 Subject: [PATCH 04/10] Added plan descriptions for a few more primitives Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/fake_primitive_test.go | 2 +- go/vt/vtgate/engine/memory_sort.go | 24 ++++++++----- go/vt/vtgate/engine/ordered_aggregate.go | 32 +++++++++++++++-- go/vt/vtgate/engine/plan_description.go | 40 ++++++++++++++++++---- go/vt/vtgate/engine/pullout_subquery.go | 17 ++++++--- go/vt/vtgate/engine/subquery.go | 10 +++++- go/vt/vtgate/planbuilder/plan_test.go | 8 ++--- 7 files changed, 105 insertions(+), 28 deletions(-) diff --git a/go/vt/vtgate/engine/fake_primitive_test.go b/go/vt/vtgate/engine/fake_primitive_test.go index 419d3c269b0..e81286ddf69 100644 --- a/go/vt/vtgate/engine/fake_primitive_test.go +++ b/go/vt/vtgate/engine/fake_primitive_test.go @@ -139,5 +139,5 @@ func wrapStreamExecute(prim Primitive, vcursor VCursor, bindVars map[string]*que } func (f *fakePrimitive) description() PlanDescription { - return PlanDescription{OperatorType: "fake - not implemented"} + return PlanDescription{OperatorType: "fake"} } diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index d1768ba93c2..b9941eba0a5 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -23,6 +23,7 @@ import ( "math" "reflect" "sort" + "strings" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" @@ -201,20 +202,27 @@ func (ms *MemorySort) description() PlanDescription { } func orderByParamsToString(i interface{}) string { - ob := i.(OrderbyParams) - return ob.String() + return i.(OrderbyParams).String() } +//GenericJoin will iterate over arrays, slices or maps, and executes the f function to get a +//string representation of each element, and then uses strings.Join() join all the strings into a single one func GenericJoin(input interface{}, f func(interface{}) string) string { sl := reflect.ValueOf(input) - str := "" - for i := 0; i < sl.Len(); i++ { - if len(str) != 0 { - str += "," + var keys []string + switch sl.Kind() { + case reflect.Slice: + for i := 0; i < sl.Len(); i++ { + keys = append(keys, f(sl.Index(i).Interface())) } - str += f(sl.Index(i).Interface()) + case reflect.Map: + for _, k := range sl.MapKeys() { + keys = append(keys, f(k.Interface())) + } + default: + panic("GenericJoin doesn't know how to deal with " + sl.Kind().String()) } - return str + return strings.Join(keys, ", ") } // sortHeap is sorted based on the orderBy params. diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index 08ffd372f19..07f433e7464 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -18,6 +18,9 @@ package engine import ( "fmt" + "strconv" + + "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/vterrors" @@ -67,6 +70,14 @@ func (ap AggregateParams) isDistinct() bool { return ap.Opcode == AggregateCountDistinct || ap.Opcode == AggregateSumDistinct } +func (ap AggregateParams) String() string { + if ap.Alias != "" { + return fmt.Sprintf("%s(%d) AS %s", ap.Opcode.String(), ap.Col, ap.Alias) + } + + return fmt.Sprintf("%s(%d)", ap.Opcode.String(), ap.Col) +} + // AggregateOpcode is the aggregation Opcode. type AggregateOpcode int @@ -394,9 +405,26 @@ func createEmptyValueFor(opcode AggregateOpcode) (sqltypes.Value, error) { return sqltypes.NULL, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "unknown aggregation %v", opcode) } +func aggregateParamsToString(in interface{}) string { + return in.(AggregateParams).String() +} + +func intToString(i interface{}) string { + return strconv.Itoa(i.(int)) +} + func (oa *OrderedAggregate) description() PlanDescription { + orderByIndexes := GenericJoin(oa.Aggregates, aggregateParamsToString) + groupBy := GenericJoin(oa.Keys, intToString) + other := map[string]string{ + "OrderBy": orderByIndexes, + "GroupBy": groupBy, + "Distinct": strconv.FormatBool(oa.HasDistinct), + } return PlanDescription{ - OperatorType: "OrderedAggregation not implemented", - Other: nil, + OperatorType: "Aggregate", + Variant: "Ordered", + TargetDestination: key.DestinationVtGate{}, + Other: other, } } diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index a7836300648..b179aa5829c 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -17,6 +17,8 @@ limitations under the License. package engine import ( + "encoding/json" + "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/vtgate/vindexes" @@ -25,16 +27,42 @@ import ( // PlanDescription is used to create a serializable representation of the Primitive tree type PlanDescription struct { OperatorType string - Variant string + Variant string `json:",omitempty"` // Keyspace specifies the keyspace to send the query to. - Keyspace *vindexes.Keyspace + Keyspace *vindexes.Keyspace `json:",omitempty"` // TargetDestination specifies an explicit target destination to send the query to. - TargetDestination key.Destination + TargetDestination key.Destination `json:",omitempty"` // TargetTabletType specifies an explicit target destination tablet type // this is only used in conjunction with TargetDestination - TargetTabletType topodatapb.TabletType - Other map[string]string - Inputs []PlanDescription + TargetTabletType topodatapb.TabletType `json:",omitempty"` + Other map[string]string `json:",omitempty"` + Inputs []PlanDescription `json:",omitempty"` +} + +// MarshalJSON serializes the PlanDescription into a JSON representation. +func (pd *PlanDescription) MarshalJSON() ([]byte, error) { + var dest string + if pd.TargetDestination != nil { + dest = pd.TargetDestination.String() + } + out := struct { + OperatorType string + Variant string `json:",omitempty"` + Keyspace *vindexes.Keyspace `json:",omitempty"` + TargetDestination string `json:",omitempty"` + TargetTabletType string `json:",omitempty"` + Other map[string]string `json:",omitempty"` + Inputs []PlanDescription `json:",omitempty"` + }{ + OperatorType: pd.OperatorType, + Variant: pd.Variant, + Keyspace: pd.Keyspace, + TargetDestination: dest, + TargetTabletType: pd.TargetTabletType.String(), + Other: pd.Other, + Inputs: pd.Inputs, + } + return json.Marshal(out) } //PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree diff --git a/go/vt/vtgate/engine/pullout_subquery.go b/go/vt/vtgate/engine/pullout_subquery.go index 7d3b00d915f..313a318a46e 100644 --- a/go/vt/vtgate/engine/pullout_subquery.go +++ b/go/vt/vtgate/engine/pullout_subquery.go @@ -19,6 +19,8 @@ package engine import ( "fmt" + "vitess.io/vitess/go/vt/key" + "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/vterrors" @@ -31,11 +33,14 @@ var _ Primitive = (*PulloutSubquery)(nil) // PulloutSubquery executes a "pulled out" subquery and stores // the results in a bind variable. type PulloutSubquery struct { - Opcode PulloutOpcode + Opcode PulloutOpcode + + // SubqueryResult and HasValues are used to send in the bindvar used in the query to the underlying primitive SubqueryResult string HasValues string - Subquery Primitive - Underlying Primitive + + Subquery Primitive + Underlying Primitive } // Inputs returns the input primitives for this join @@ -154,7 +159,11 @@ func (ps *PulloutSubquery) execSubquery(vcursor VCursor, bindVars map[string]*qu } func (ps *PulloutSubquery) description() PlanDescription { - return PlanDescription{OperatorType: "pullout subquery not implemented"} + return PlanDescription{ + OperatorType: "Subquery", + Variant: ps.Opcode.String(), + TargetDestination: key.DestinationVtGate{}, + } } // PulloutOpcode is a number representing the opcode diff --git a/go/vt/vtgate/engine/subquery.go b/go/vt/vtgate/engine/subquery.go index 9ef181fa45f..1afa3ec728c 100644 --- a/go/vt/vtgate/engine/subquery.go +++ b/go/vt/vtgate/engine/subquery.go @@ -18,6 +18,7 @@ package engine import ( "vitess.io/vitess/go/sqltypes" + "vitess.io/vitess/go/vt/key" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -104,5 +105,12 @@ func (sq *Subquery) buildFields(inner *sqltypes.Result) []*querypb.Field { } func (sq *Subquery) description() PlanDescription { - return PlanDescription{OperatorType: "subquery - not implemented"} + other := map[string]string{ + "Columns": GenericJoin(sq.Cols, intToString), + } + return PlanDescription{ + OperatorType: "Subquery", + TargetDestination: key.DestinationVtGate{}, + Other: other, + } } diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index aa5da5fd81d..ba1e3756300 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -301,13 +301,9 @@ func getPlanOrErrorOutput(err error, plan *engine.Plan) string { } descr := engine.PrimitiveToPlanDescription(plan.Instructions) - sss, _ := json.MarshalIndent(descr, "", " ") - fmt.Println(string(sss)) - bout, _ := json.MarshalIndent(testPlan{ - Original: plan.Original, - Instructions: plan.Instructions, - }, "", " ") + bout, _ := json.MarshalIndent(descr, " ", " ") + fmt.Println(string(bout)) return string(bout) } From 63d340b5a5fcaa2d05ca491f930d63112f5f5612 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 2 Apr 2020 17:01:43 +0200 Subject: [PATCH 05/10] Manual json marshalling Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/delete.go | 4 +- go/vt/vtgate/engine/fake_primitive_test.go | 4 +- go/vt/vtgate/engine/insert.go | 4 +- go/vt/vtgate/engine/join.go | 4 +- go/vt/vtgate/engine/limit.go | 4 +- go/vt/vtgate/engine/memory_sort.go | 4 +- go/vt/vtgate/engine/merge_sort.go | 4 +- go/vt/vtgate/engine/ordered_aggregate.go | 4 +- go/vt/vtgate/engine/plan_description.go | 96 ++++++++++++++------ go/vt/vtgate/engine/plan_description_test.go | 14 +-- go/vt/vtgate/engine/primitive.go | 2 +- go/vt/vtgate/engine/pullout_subquery.go | 4 +- go/vt/vtgate/engine/route.go | 6 +- go/vt/vtgate/engine/subquery.go | 4 +- go/vt/vtgate/engine/update.go | 4 +- go/vt/vtgate/engine/vindex_func.go | 4 +- 16 files changed, 101 insertions(+), 65 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 9074f4bb618..a455969631e 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -237,12 +237,12 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] return res, vterrors.Aggregate(errs) } -func (del *Delete) description() PlanDescription { +func (del *Delete) description() PrimitiveDescription { other := map[string]string{ "Query": del.Query, "TableName": del.GetTableName(), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Delete", Keyspace: del.Keyspace, Variant: del.Opcode.String(), diff --git a/go/vt/vtgate/engine/fake_primitive_test.go b/go/vt/vtgate/engine/fake_primitive_test.go index e81286ddf69..d046ed66aca 100644 --- a/go/vt/vtgate/engine/fake_primitive_test.go +++ b/go/vt/vtgate/engine/fake_primitive_test.go @@ -138,6 +138,6 @@ func wrapStreamExecute(prim Primitive, vcursor VCursor, bindVars map[string]*que return result, err } -func (f *fakePrimitive) description() PlanDescription { - return PlanDescription{OperatorType: "fake"} +func (f *fakePrimitive) description() PrimitiveDescription { + return PrimitiveDescription{OperatorType: "fake"} } diff --git a/go/vt/vtgate/engine/insert.go b/go/vt/vtgate/engine/insert.go index 829988c6e49..c26e90fabd2 100644 --- a/go/vt/vtgate/engine/insert.go +++ b/go/vt/vtgate/engine/insert.go @@ -615,14 +615,14 @@ func insertVarName(col sqlparser.ColIdent, rowNum int) string { return "_" + col.CompliantName() + strconv.Itoa(rowNum) } -func (ins *Insert) description() PlanDescription { +func (ins *Insert) description() PrimitiveDescription { other := map[string]string{ "Query": ins.Query, "TableName": ins.GetTableName(), "MultiShardAutocommit": strconv.FormatBool(ins.MultiShardAutocommit), "QueryTimeout": strconv.Itoa(ins.QueryTimeout), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Insert", Keyspace: ins.Keyspace, Variant: ins.Opcode.String(), diff --git a/go/vt/vtgate/engine/join.go b/go/vt/vtgate/engine/join.go index c81d6ae0ce5..db897f5cafa 100644 --- a/go/vt/vtgate/engine/join.go +++ b/go/vt/vtgate/engine/join.go @@ -257,12 +257,12 @@ func combineVars(bv1, bv2 map[string]*querypb.BindVariable) map[string]*querypb. return out } -func (jn *Join) description() PlanDescription { +func (jn *Join) description() PrimitiveDescription { other := map[string]string{ "TableName": jn.GetTableName(), "JoinColumnIndexes": strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jn.Cols)), ","), "[]"), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Join", Variant: jn.Opcode.String(), TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index 18a369064c6..882161ea3d4 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -203,7 +203,7 @@ func (l *Limit) fetchOffset(bindVars map[string]*querypb.BindVariable) (int, err return offset, nil } -func (l *Limit) description() PlanDescription { +func (l *Limit) description() PrimitiveDescription { // TODO: There's got to be a better way count, err := l.Count.MarshalJSON() if err != nil { @@ -219,7 +219,7 @@ func (l *Limit) description() PlanDescription { "Offset": string(offset), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Limit", Other: other, TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index b9941eba0a5..a94a1a27c26 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -187,13 +187,13 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int return count, nil } -func (ms *MemorySort) description() PlanDescription { +func (ms *MemorySort) description() PrimitiveDescription { orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) other := map[string]string{ "UpperLimit": ms.UpperLimit.Value.String(), "OrderBy": orderByIndexes, } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Sort", Variant: "Memory", TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index e139e76d9cd..64a5376f66a 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -157,12 +157,12 @@ func (ms *MergeSort) StreamExecute(vcursor VCursor, bindVars map[string]*querypb return nil } -func (ms *MergeSort) description() PlanDescription { +func (ms *MergeSort) description() PrimitiveDescription { orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) other := map[string]string{ "OrderBy": orderByIndexes, } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Sort", Variant: "Merge", TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index 07f433e7464..443582e06df 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -413,7 +413,7 @@ func intToString(i interface{}) string { return strconv.Itoa(i.(int)) } -func (oa *OrderedAggregate) description() PlanDescription { +func (oa *OrderedAggregate) description() PrimitiveDescription { orderByIndexes := GenericJoin(oa.Aggregates, aggregateParamsToString) groupBy := GenericJoin(oa.Keys, intToString) other := map[string]string{ @@ -421,7 +421,7 @@ func (oa *OrderedAggregate) description() PlanDescription { "GroupBy": groupBy, "Distinct": strconv.FormatBool(oa.HasDistinct), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Aggregate", Variant: "Ordered", TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index b179aa5829c..a56e6434eae 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -17,6 +17,7 @@ limitations under the License. package engine import ( + "bytes" "encoding/json" "vitess.io/vitess/go/vt/key" @@ -24,49 +25,84 @@ import ( "vitess.io/vitess/go/vt/vtgate/vindexes" ) -// PlanDescription is used to create a serializable representation of the Primitive tree -type PlanDescription struct { +// PrimitiveDescription is used to create a serializable representation of the Primitive tree +type PrimitiveDescription struct { OperatorType string - Variant string `json:",omitempty"` + Variant string // Keyspace specifies the keyspace to send the query to. - Keyspace *vindexes.Keyspace `json:",omitempty"` + Keyspace *vindexes.Keyspace // TargetDestination specifies an explicit target destination to send the query to. - TargetDestination key.Destination `json:",omitempty"` + TargetDestination key.Destination // TargetTabletType specifies an explicit target destination tablet type // this is only used in conjunction with TargetDestination - TargetTabletType topodatapb.TabletType `json:",omitempty"` - Other map[string]string `json:",omitempty"` - Inputs []PlanDescription `json:",omitempty"` + TargetTabletType topodatapb.TabletType + Other map[string]string + Inputs []PrimitiveDescription } // MarshalJSON serializes the PlanDescription into a JSON representation. -func (pd *PlanDescription) MarshalJSON() ([]byte, error) { - var dest string +// We do this rather manual thing here so the `other` map looks like +//fields belonging to pd and not a map in a field. +func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) { + buf := &bytes.Buffer{} + buf.WriteString("{") + + if err := marshalAdd("", buf, "OperatorType", pd.OperatorType); err != nil { + return nil, err + } + if err := marshalAdd(",", buf, "Variant", pd.Variant); err != nil { + return nil, err + } + if pd.Keyspace != nil { + if err := marshalAdd(",", buf, "Keyspace", pd.Keyspace); err != nil { + return nil, err + } + } if pd.TargetDestination != nil { - dest = pd.TargetDestination.String() + s := pd.TargetDestination.String() + dest := s[11:] // TODO: All these start with Destination. We should fix that instead if trimming it out here + + if err := marshalAdd(",", buf, "TargetDestination", dest); err != nil { + return nil, err + } + } + if pd.TargetTabletType != topodatapb.TabletType_UNKNOWN { + if err := marshalAdd(",", buf, "TargetTabletType", pd.TargetTabletType.String()); err != nil { + return nil, err + } + } + for k, v := range pd.Other { + if err := marshalAdd(",", buf, k, v); err != nil { + return nil, err + } } - out := struct { - OperatorType string - Variant string `json:",omitempty"` - Keyspace *vindexes.Keyspace `json:",omitempty"` - TargetDestination string `json:",omitempty"` - TargetTabletType string `json:",omitempty"` - Other map[string]string `json:",omitempty"` - Inputs []PlanDescription `json:",omitempty"` - }{ - OperatorType: pd.OperatorType, - Variant: pd.Variant, - Keyspace: pd.Keyspace, - TargetDestination: dest, - TargetTabletType: pd.TargetTabletType.String(), - Other: pd.Other, - Inputs: pd.Inputs, + + if len(pd.Inputs) > 0 { + if err := marshalAdd(",", buf, "Inputs", pd.Inputs); err != nil { + return nil, err + } + } + + buf.WriteString("}") + + var out bytes.Buffer + json.Indent(&out, buf.Bytes(), " ", " ") + + return out.Bytes(), nil +} + +func marshalAdd(prepend string, buf *bytes.Buffer, name string, obj interface{}) error { + buf.WriteString(prepend + `"` + name + `":`) + b, err := json.Marshal(obj) + if err != nil { + return err } - return json.Marshal(out) + buf.Write(b) + return nil } //PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree -func PrimitiveToPlanDescription(in Primitive) PlanDescription { +func PrimitiveToPlanDescription(in Primitive) PrimitiveDescription { this := in.description() for _, input := range in.Inputs() { @@ -74,7 +110,7 @@ func PrimitiveToPlanDescription(in Primitive) PlanDescription { } if len(in.Inputs()) == 0 { - this.Inputs = []PlanDescription{} + this.Inputs = []PrimitiveDescription{} } return this diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 79932bd06e2..ca226de303a 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -34,7 +34,7 @@ func TestCreateRoutePlanDescription(t *testing.T) { planDescription := PrimitiveToPlanDescription(route) - expected := PlanDescription{ + expected := PrimitiveDescription{ OperatorType: "Route", Variant: "SelectScatter", Keyspace: &vindexes.Keyspace{Name: "ks"}, @@ -44,7 +44,7 @@ func TestCreateRoutePlanDescription(t *testing.T) { "Query": route.Query, "TableName": route.TableName, }, - Inputs: []PlanDescription{}, + Inputs: []PrimitiveDescription{}, } if diff := cmp.Diff(planDescription, expected); diff != "" { @@ -82,13 +82,13 @@ func TestPlanDescriptionWithInputs(t *testing.T) { planDescription := PrimitiveToPlanDescription(limit) - expected := PlanDescription{ + expected := PrimitiveDescription{ OperatorType: "Limit", Other: map[string]string{ "Count": "12", "Offset": "4", }, - Inputs: []PlanDescription{routeDescr}, + Inputs: []PrimitiveDescription{routeDescr}, } if diff := cmp.Diff(planDescription, expected); diff != "" { @@ -101,8 +101,8 @@ func TestPlanDescriptionWithInputs(t *testing.T) { } -func getDescriptionFor(route *Route) PlanDescription { - return PlanDescription{ +func getDescriptionFor(route *Route) PrimitiveDescription { + return PrimitiveDescription{ OperatorType: "Route", Variant: routeName[route.Opcode], Keyspace: &vindexes.Keyspace{Name: "ks"}, @@ -112,6 +112,6 @@ func getDescriptionFor(route *Route) PlanDescription { "Query": route.Query, "TableName": route.TableName, }, - Inputs: []PlanDescription{}, + Inputs: []PrimitiveDescription{}, } } diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go index 87450f6b62b..2eba4077dd8 100644 --- a/go/vt/vtgate/engine/primitive.go +++ b/go/vt/vtgate/engine/primitive.go @@ -169,7 +169,7 @@ type Primitive interface { // description is the description, sans the inputs, of this Primitive. // to get the plan description with all children, use PrimitiveToPlanDescription() - description() PlanDescription + description() PrimitiveDescription } type noInputs struct{} diff --git a/go/vt/vtgate/engine/pullout_subquery.go b/go/vt/vtgate/engine/pullout_subquery.go index 313a318a46e..3c0df478a17 100644 --- a/go/vt/vtgate/engine/pullout_subquery.go +++ b/go/vt/vtgate/engine/pullout_subquery.go @@ -158,8 +158,8 @@ func (ps *PulloutSubquery) execSubquery(vcursor VCursor, bindVars map[string]*qu return combinedVars, nil } -func (ps *PulloutSubquery) description() PlanDescription { - return PlanDescription{ +func (ps *PulloutSubquery) description() PrimitiveDescription { + return PrimitiveDescription{ OperatorType: "Subquery", Variant: ps.Opcode.String(), TargetDestination: key.DestinationVtGate{}, diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 789f436ac99..21ce1b7f8e8 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -155,7 +155,7 @@ func (route *Route) MarshalJSON() ([]byte, error) { TruncateColumnCount: route.TruncateColumnCount, QueryTimeout: route.QueryTimeout, ScatterErrorsAsWarnings: route.ScatterErrorsAsWarnings, - Table: route.TableName, + Table: route.TableName, } return jsonutil.MarshalNoEscape(marshalRoute) } @@ -567,12 +567,12 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) return shardVars } -func (route *Route) description() PlanDescription { +func (route *Route) description() PrimitiveDescription { other := map[string]string{ "Query": route.Query, "TableName": route.TableName, } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Route", Variant: routeName[route.Opcode], Keyspace: route.Keyspace, diff --git a/go/vt/vtgate/engine/subquery.go b/go/vt/vtgate/engine/subquery.go index 1afa3ec728c..4d3a665b113 100644 --- a/go/vt/vtgate/engine/subquery.go +++ b/go/vt/vtgate/engine/subquery.go @@ -104,11 +104,11 @@ func (sq *Subquery) buildFields(inner *sqltypes.Result) []*querypb.Field { return fields } -func (sq *Subquery) description() PlanDescription { +func (sq *Subquery) description() PrimitiveDescription { other := map[string]string{ "Columns": GenericJoin(sq.Cols, intToString), } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Subquery", TargetDestination: key.DestinationVtGate{}, Other: other, diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index 5162de54fdb..c19571dc6db 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -266,7 +266,7 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] return result, vterrors.Aggregate(errs) } -func (upd *Update) description() PlanDescription { +func (upd *Update) description() PrimitiveDescription { changedVindexes := "" for vindex := range upd.ChangedVindexValues { if len(changedVindexes) != 0 { @@ -279,7 +279,7 @@ func (upd *Update) description() PlanDescription { "TableName": upd.GetTableName(), "Vindexes": changedVindexes, } - return PlanDescription{ + return PrimitiveDescription{ OperatorType: "Update", Keyspace: upd.Keyspace, Variant: upd.Opcode.String(), diff --git a/go/vt/vtgate/engine/vindex_func.go b/go/vt/vtgate/engine/vindex_func.go index 6b10c97e92e..e9c2cc25240 100644 --- a/go/vt/vtgate/engine/vindex_func.go +++ b/go/vt/vtgate/engine/vindex_func.go @@ -194,6 +194,6 @@ func (vf *VindexFunc) buildRow(id sqltypes.Value, ksid []byte, kr *topodatapb.Ke return row } -func (vf *VindexFunc) description() PlanDescription { - return PlanDescription{OperatorType: "vindexfunc - not implemented"} +func (vf *VindexFunc) description() PrimitiveDescription { + return PrimitiveDescription{OperatorType: "vindexfunc - not implemented"} } From 7c9ef8bb99f42c1162471296ee28bb7d05870a69 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 2 Apr 2020 17:13:28 +0200 Subject: [PATCH 06/10] Small prettifying of some plans Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/limit.go | 18 ++++++------------ go/vt/vtgate/engine/memory_sort.go | 7 ++++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index 882161ea3d4..80ad701acff 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -204,19 +204,13 @@ func (l *Limit) fetchOffset(bindVars map[string]*querypb.BindVariable) (int, err } func (l *Limit) description() PrimitiveDescription { - // TODO: There's got to be a better way - count, err := l.Count.MarshalJSON() - if err != nil { - count = []byte("?") - } - offset, err := l.Offset.MarshalJSON() - if err != nil { - offset = []byte("?") - } + other := map[string]string{} - other := map[string]string{ - "Count": string(count), - "Offset": string(offset), + if !l.Count.IsNull() { + other["Count"] = l.Count.Value.String() + } + if !l.Offset.IsNull() { + other["Offset"] = l.Offset.Value.String() } return PrimitiveDescription{ diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index a94a1a27c26..852ad2f697d 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -189,9 +189,10 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int func (ms *MemorySort) description() PrimitiveDescription { orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) - other := map[string]string{ - "UpperLimit": ms.UpperLimit.Value.String(), - "OrderBy": orderByIndexes, + value := ms.UpperLimit.Value + other := map[string]string{"OrderBy": orderByIndexes} + if !value.IsNull() { + other["UpperLimit"] = value.String() } return PrimitiveDescription{ OperatorType: "Sort", From 5b1eece0160d1aa72a02873f5f0e5eda6292abe2 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 2 Apr 2020 20:38:03 +0200 Subject: [PATCH 07/10] Renamed json field Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/ordered_aggregate.go | 8 +- go/vt/vtgate/engine/plan_description.go | 28 +- go/vt/vtgate/engine/primitive.go | 58 +- go/vt/vtgate/engine/route.go | 4 +- go/vt/vtgate/engine/send.go | 14 +- go/vt/vtgate/engine/update.go | 12 +- go/vt/vtgate/planbuilder/plan_test.go | 13 +- .../planbuilder/testdata/aggr_cases.txt | 1466 +++++------- .../planbuilder/testdata/bypass_cases.txt | 28 +- .../vtgate/planbuilder/testdata/dml_cases.txt | 1532 +++++-------- .../planbuilder/testdata/filter_cases.txt | 1045 ++++----- .../planbuilder/testdata/from_cases.txt | 1994 +++++++++-------- .../testdata/memory_sort_cases.txt | 801 +++---- .../testdata/postprocess_cases.txt | 1065 ++++----- .../planbuilder/testdata/select_cases.txt | 1044 ++++----- .../planbuilder/testdata/symtab_cases.txt | 54 +- .../testdata/vindex_func_cases.txt | 376 +--- .../planbuilder/testdata/wireup_cases.txt | 936 ++++---- 18 files changed, 4759 insertions(+), 5719 deletions(-) diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index 443582e06df..c6ee9864371 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -414,12 +414,12 @@ func intToString(i interface{}) string { } func (oa *OrderedAggregate) description() PrimitiveDescription { - orderByIndexes := GenericJoin(oa.Aggregates, aggregateParamsToString) + aggregates := GenericJoin(oa.Aggregates, aggregateParamsToString) groupBy := GenericJoin(oa.Keys, intToString) other := map[string]string{ - "OrderBy": orderByIndexes, - "GroupBy": groupBy, - "Distinct": strconv.FormatBool(oa.HasDistinct), + "Aggregates": aggregates, + "GroupBy": groupBy, + "Distinct": strconv.FormatBool(oa.HasDistinct), } return PrimitiveDescription{ OperatorType: "Aggregate", diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index a56e6434eae..4b2267041ab 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -19,6 +19,7 @@ package engine import ( "bytes" "encoding/json" + "sort" "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" @@ -71,10 +72,9 @@ func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) { return nil, err } } - for k, v := range pd.Other { - if err := marshalAdd(",", buf, k, v); err != nil { - return nil, err - } + err := addMap(pd.Other, buf) + if err != nil { + return nil, err } if len(pd.Inputs) > 0 { @@ -85,10 +85,24 @@ func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) { buf.WriteString("}") - var out bytes.Buffer - json.Indent(&out, buf.Bytes(), " ", " ") + return buf.Bytes(), nil +} - return out.Bytes(), nil +func addMap(input map[string]string, buf *bytes.Buffer) error { + mk := make([]string, len(input)) + i := 0 + for k := range input { + mk[i] = k + i++ + } + sort.Strings(mk) + for _, k := range mk { + v := input[k] + if err := marshalAdd(",", buf, k, v); err != nil { + return err + } + } + return nil } func marshalAdd(prepend string, buf *bytes.Buffer, name string, obj interface{}) error { diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go index 2eba4077dd8..b664d2e7a26 100644 --- a/go/vt/vtgate/engine/primitive.go +++ b/go/vt/vtgate/engine/primitive.go @@ -17,6 +17,7 @@ limitations under the License. package engine import ( + "encoding/json" "sync" "time" @@ -79,25 +80,16 @@ type VCursor interface { // each node does its part by combining the results of the // sub-nodes. type Plan struct { - // Original is the original query. - Original string `json:",omitempty"` - // Instructions contains the instructions needed to - // fulfil the query. - Instructions Primitive `json:",omitempty"` - // Mutex to protect the stats - mu sync.Mutex - // Count of times this plan was executed - ExecCount uint64 `json:",omitempty"` - // Total execution time - ExecTime time.Duration `json:",omitempty"` - // Total number of shard queries - ShardQueries uint64 `json:",omitempty"` - // Total number of rows - Rows uint64 `json:",omitempty"` - // Total number of errors - Errors uint64 `json:",omitempty"` - // Stores BindVars needed to be provided as part of expression rewriting - sqlparser.BindVarNeeds `json:"-"` + Original string // Original is the original query. + Instructions Primitive // Instructions contains the instructions needed to fulfil the query. + sqlparser.BindVarNeeds // Stores BindVars needed to be provided as part of expression rewriting + + mu sync.Mutex // Mutex to protect the fields below + ExecCount uint64 // Count of times this plan was executed + ExecTime time.Duration // Total execution time + ShardQueries uint64 // Total number of shard queries + Rows uint64 // Total number of rows + Errors uint64 // Total number of errors } // AddStats updates the plan execution statistics @@ -152,6 +144,34 @@ func (p *Plan) Size() int { return 1 } +//MarshalJSON serializes the plan into a JSON representation. +func (p *Plan) MarshalJSON() ([]byte, error) { + var instructions *PrimitiveDescription + if p.Instructions != nil { + description := PrimitiveToPlanDescription(p.Instructions) + instructions = &description + } + + marshalPlan := struct { + Original string `json:",omitempty"` + Instructions *PrimitiveDescription `json:",omitempty"` + ExecCount uint64 `json:",omitempty"` + ExecTime time.Duration `json:",omitempty"` + ShardQueries uint64 `json:",omitempty"` + Rows uint64 `json:",omitempty"` + Errors uint64 `json:",omitempty"` + }{ + Original: p.Original, + Instructions: instructions, + ExecCount: p.ExecCount, + ExecTime: p.ExecTime, + ShardQueries: p.ShardQueries, + Rows: p.Rows, + Errors: p.Errors, + } + return json.Marshal(marshalPlan) +} + // Primitive is the building block of the engine execution plan. They form a tree structure, where the leaves typically // issue queries to one or more vttablet. // During execution, the Primitive's pass Result objects up the tree structure, until reaching the root, diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 21ce1b7f8e8..4c4103d7de9 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -569,8 +569,8 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) func (route *Route) description() PrimitiveDescription { other := map[string]string{ - "Query": route.Query, - "TableName": route.TableName, + "Query": route.Query, + "Table": route.TableName, } return PrimitiveDescription{ OperatorType: "Route", diff --git a/go/vt/vtgate/engine/send.go b/go/vt/vtgate/engine/send.go index 8a8d0a880fb..ec26a0aa8cb 100644 --- a/go/vt/vtgate/engine/send.go +++ b/go/vt/vtgate/engine/send.go @@ -21,7 +21,6 @@ type Send struct { 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 // Query specifies the query to be executed. @@ -114,3 +113,16 @@ func (s *Send) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVar func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error) { return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable") } + +func (s *Send) description() PrimitiveDescription { + other := map[string]string{ + "Query": s.Query, + "Table": s.GetTableName(), + } + return PrimitiveDescription{ + OperatorType: "Send", + Keyspace: s.Keyspace, + TargetDestination: s.TargetDestination, + Other: other, + } +} diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index c19571dc6db..7d10b895033 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -18,6 +18,8 @@ package engine import ( "fmt" + "sort" + "strings" "time" topodatapb "vitess.io/vitess/go/vt/proto/topodata" @@ -267,17 +269,15 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] } func (upd *Update) description() PrimitiveDescription { - changedVindexes := "" + var changedVindexes []string for vindex := range upd.ChangedVindexValues { - if len(changedVindexes) != 0 { - changedVindexes += "," - } - changedVindexes += vindex + changedVindexes = append(changedVindexes, vindex) } + sort.Strings(changedVindexes) other := map[string]string{ "Query": upd.Query, "TableName": upd.GetTableName(), - "Vindexes": changedVindexes, + "Vindexes": strings.Join(changedVindexes, ", "), } return PrimitiveDescription{ OperatorType: "Update", diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index ba1e3756300..44ee48ea551 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -257,13 +257,6 @@ func (vw *vschemaWrapper) TargetString() string { return "targetString" } -// For the purposes of this set of tests, just compare the actual plan -// and ignore all the metrics. -type testPlan struct { - Original string `json:",omitempty"` - Instructions engine.Primitive `json:",omitempty"` -} - func testFile(t *testing.T, filename, tempDir string, vschema *vschemaWrapper) { t.Run(filename, func(t *testing.T) { expected := &strings.Builder{} @@ -299,11 +292,7 @@ func getPlanOrErrorOutput(err error, plan *engine.Plan) string { if err != nil { return err.Error() } - - descr := engine.PrimitiveToPlanDescription(plan.Instructions) - - bout, _ := json.MarshalIndent(descr, " ", " ") - fmt.Println(string(bout)) + bout, _ := json.MarshalIndent(plan, "", " ") return string(bout) } diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt index 2ca7229980e..f32709be96c 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt @@ -5,13 +5,13 @@ { "Original": "select count(*), col from unsharded", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select count(*), col from unsharded", - "FieldQuery": "select count(*), col from unsharded where 1 != 1", "Table": "unsharded" } } @@ -21,17 +21,14 @@ { "Original": "select count(*), col from user where id = 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select count(*), col from user where id = 1", - "FieldQuery": "select count(*), col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -41,13 +38,14 @@ { "Original": "select fun(1), col from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select fun(1), col from user", - "FieldQuery": "select fun(1), col from user where 1 != 1", "Table": "user" } } @@ -57,13 +55,14 @@ { "Original": "select distinct col1, id from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select distinct col1, id from user", - "FieldQuery": "select col1, id from user where 1 != 1", "Table": "user" } } @@ -73,13 +72,14 @@ { "Original": "select distinct col1, id from user group by col1", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select distinct col1, id from user group by col1", - "FieldQuery": "select col1, id from user where 1 != 1 group by col1", "Table": "user" } } @@ -89,43 +89,25 @@ { "Original": "select count(*), a, textcol1, b from user group by a, textcol1, b", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "1, 4, 3", + "Inputs": [ { - "Opcode": "count", - "Col": 0 - } - ], - "Keys": [ - 1, - 4, - 3 - ], - "TruncateColumnCount": 4, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select count(*), a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by a asc, textcol1 asc, b asc", - "FieldQuery": "select count(*), a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", - "OrderBy": [ - { - "Col": 1, - "Desc": false - }, - { - "Col": 4, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 3, - "Desc": false - } - ], - "TruncateColumnCount": 5, - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select count(*), a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by a asc, textcol1 asc, b asc", + "Table": "user" + } + ] } } @@ -134,57 +116,33 @@ { "Original": "select count(*) k, a, textcol1, b from user group by a, textcol1, b order by k, textcol1", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "0 ASC, 4 ASC", + "Inputs": [ { - "Col": 0, - "Desc": false - }, - { - "Col": 4, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 0 - } - ], - "Keys": [ - 1, - 4, - 3 - ], - "TruncateColumnCount": 5, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by textcol1 asc, a asc, b asc", - "FieldQuery": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", - "OrderBy": [ - { - "Col": 4, - "Desc": false - }, + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "1, 4, 3", + "Inputs": [ { - "Col": 1, - "Desc": false - }, - { - "Col": 3, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by textcol1 asc, a asc, b asc", + "Table": "user" } - ], - "TruncateColumnCount": 5, - "Table": "user" + ] } - } + ] } } @@ -193,23 +151,25 @@ { "Original": "select count(*) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select count(*) from user", - "FieldQuery": "select count(*) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -218,23 +178,25 @@ { "Original": "select sum(col) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "sum(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "sum", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select sum(col) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select sum(col) from user", - "FieldQuery": "select sum(col) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -243,23 +205,25 @@ { "Original": "select min(col) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "min(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "min", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select min(col) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select min(col) from user", - "FieldQuery": "select min(col) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -268,23 +232,25 @@ { "Original": "select max(col) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "max(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "max", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select max(col) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select max(col) from user", - "FieldQuery": "select max(col) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -293,36 +259,25 @@ { "Original": "select distinct col1, col2 from user group by col1", "Instructions": { - "Aggregates": null, - "Keys": [ - 0, - 1, - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select distinct col1, col2 from user group by col1 order by col1 asc, col2 asc, col1 asc", - "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 1, - "Desc": false + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "", + "Distinct": "false", + "GroupBy": "0, 1, 0", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select distinct col1, col2 from user group by col1 order by col1 asc, col2 asc, col1 asc", + "Table": "user" + } + ] } } @@ -331,30 +286,33 @@ { "Original": "select user.a, t.b from user join (select count(*) b from unsharded) as t", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.a from user", - "FieldQuery": "select user.a from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.a from user", + "Table": "user" }, - "Query": "select t.b from (select count(*) as b from unsharded) as t", - "FieldQuery": "select t.b from (select count(*) as b from unsharded where 1 != 1) as t where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select t.b from (select count(*) as b from unsharded) as t", + "Table": "unsharded" + } ] } } @@ -364,13 +322,14 @@ { "Original": "select id, count(*) from user group by id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id, count(*) from user group by id", - "FieldQuery": "select id, count(*) from user where 1 != 1 group by id", "Table": "user" } } @@ -380,13 +339,14 @@ { "Original": "select id, col, count(*) from user group by id, col", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id, col, count(*) from user group by id, col", - "FieldQuery": "select id, col, count(*) from user where 1 != 1 group by id, col", "Table": "user" } } @@ -396,31 +356,25 @@ { "Original": "select col, count(*) from user group by col", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "count", - "Col": 1 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col, count(*) from user group by col order by col asc", + "Table": "user" } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col, count(*) from user group by col order by col asc", - "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } } @@ -429,31 +383,25 @@ { "Original": "select name, count(*) from user group by name", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "count", - "Col": 1 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select name, count(*) from user group by name order by name asc", + "Table": "user" } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select name, count(*) from user group by name order by name asc", - "FieldQuery": "select name, count(*) from user where 1 != 1 group by name", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } } @@ -462,13 +410,14 @@ { "Original": "select id, 1+count(*) from user group by id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id, 1 + count(*) from user group by id", - "FieldQuery": "select id, 1 + count(*) from user where 1 != 1 group by id", "Table": "user" } } @@ -478,13 +427,14 @@ { "Original": "select id as val, 1+count(*) from user group by val", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id as val, 1 + count(*) from user group by val", - "FieldQuery": "select id as val, 1 + count(*) from user where 1 != 1 group by val", "Table": "user" } } @@ -494,13 +444,14 @@ { "Original": "select val as id, 1+count(*) from user group by user.id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select val as id, 1 + count(*) from user group by user.id", - "FieldQuery": "select val as id, 1 + count(*) from user where 1 != 1 group by user.id", "Table": "user" } } @@ -510,13 +461,14 @@ { "Original": "select *, id, 1+count(*) from user group by id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select *, id, 1 + count(*) from user group by id", - "FieldQuery": "select *, id, 1 + count(*) from user where 1 != 1 group by id", "Table": "user" } } @@ -526,17 +478,14 @@ { "Original": "select id, count(*) c from user group by id having id=1 and c=10", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id, count(*) as c from user group by id having id = 1 and c = 10", - "FieldQuery": "select id, count(*) as c from user where 1 != 1 group by id", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -546,28 +495,33 @@ { "Original": "select a from (select count(*) as a from user) t", "Instructions": { - "Cols": [ - 0 - ], - "Subquery": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 0 - } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select count(*) as a from user", - "FieldQuery": "select count(*) as a from user where 1 != 1", - "Table": "user" + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "0", + "Inputs": [ + { + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select count(*) as a from user", + "Table": "user" + } + ] } - } + ] } } @@ -576,23 +530,25 @@ { "Original": "select id, count(*) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 1 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id, count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select id, count(*) from user", - "FieldQuery": "select id, count(*) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -601,26 +557,25 @@ { "Original": "select distinct col from user", "Instructions": { - "Aggregates": null, - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select distinct col from user order by col asc", - "FieldQuery": "select col from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select distinct col from user order by col asc", + "Table": "user" + } + ] } } @@ -629,26 +584,25 @@ { "Original": "select col from user group by col", "Instructions": { - "Aggregates": null, - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user group by col order by col asc", - "FieldQuery": "select col from user where 1 != 1 group by col", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user group by col order by col asc", + "Table": "user" + } + ] } } @@ -657,13 +611,14 @@ { "Original": "select id, count(distinct col) from user group by id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id, count(distinct col) from user group by id", - "FieldQuery": "select id, count(distinct col) from user where 1 != 1 group by id", "Table": "user" } } @@ -673,31 +628,25 @@ { "Original": "select col, count(distinct id) from user group by col", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "count", - "Col": 1 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col, count(distinct id) from user group by col order by col asc", + "Table": "user" } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col, count(distinct id) from user group by col order by col asc", - "FieldQuery": "select col, count(distinct id) from user where 1 != 1 group by col", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } } @@ -706,37 +655,25 @@ { "Original": "select col1, count(distinct col2) from user group by col1", "Instructions": { - "HasDistinct": true, - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count_distinct(1) AS count(distinct col2)", + "Distinct": "true", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "count_distinct", - "Col": 1, - "Alias": "count(distinct col2)" - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", - "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", - "OrderBy": [ - { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 1, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", + "Table": "user" + } + ] } } @@ -745,31 +682,25 @@ { "Original": "select count(distinct col2) from user", "Instructions": { - "HasDistinct": true, - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count_distinct(0) AS count(distinct col2)", + "Distinct": "true", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count_distinct", - "Col": 0, - "Alias": "count(distinct col2)" + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col2 from user group by col2 order by col2 asc", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col2 from user group by col2 order by col2 asc", - "FieldQuery": "select col2 from user where 1 != 1 group by col2", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } } @@ -778,37 +709,25 @@ { "Original": "select col1, count(distinct col2) c2 from user group by col1", "Instructions": { - "HasDistinct": true, - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count_distinct(1) AS c2", + "Distinct": "true", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "count_distinct", - "Col": 1, - "Alias": "c2" - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", - "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", - "OrderBy": [ - { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 1, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", + "Table": "user" + } + ] } } @@ -817,37 +736,25 @@ { "Original": "select col1, sum(distinct col2) from user group by col1", "Instructions": { - "HasDistinct": true, - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "sum_distinct(1) AS sum(distinct col2)", + "Distinct": "true", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "sum_distinct", - "Col": 1, - "Alias": "sum(distinct col2)" - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", - "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", - "OrderBy": [ - { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 1, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", + "Table": "user" + } + ] } } @@ -856,31 +763,25 @@ { "Original": "select col1, min(distinct col2) from user group by col1", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "min(1)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Opcode": "min", - "Col": 1 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col1, min(distinct col2) from user group by col1 order by col1 asc", + "Table": "user" } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1, min(distinct col2) from user group by col1 order by col1 asc", - "FieldQuery": "select col1, min(distinct col2) from user where 1 != 1 group by col1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } } @@ -889,47 +790,33 @@ { "Original": "select col1, count(distinct col2) k from user group by col1 order by k", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "1 ASC", + "Inputs": [ { - "Col": 1, - "Desc": false - } - ], - "Input": { - "HasDistinct": true, - "Aggregates": [ - { - "Opcode": "count_distinct", - "Col": 1, - "Alias": "k" - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", - "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count_distinct(1) AS k", + "Distinct": "true", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false - }, - { - "Col": 1, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -942,36 +829,25 @@ { "Original": "select a, b, count(*) from user group by b, a", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "1, 0", + "Inputs": [ { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 1, - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) from user group by b, a order by b asc, a asc", - "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by b, a", - "OrderBy": [ - { - "Col": 1, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) from user group by b, a order by b asc, a asc", + "Table": "user" + } + ] } } @@ -980,36 +856,25 @@ { "Original": "select a, b, count(*) from user group by 2, 1", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "1, 0", + "Inputs": [ { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 1, - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) from user group by 2, 1 order by b asc, a asc", - "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by 2, 1", - "OrderBy": [ - { - "Col": 1, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) from user group by 2, 1 order by b asc, a asc", + "Table": "user" + } + ] } } @@ -1018,26 +883,25 @@ { "Original": "select col from user group by 1", "Instructions": { - "Aggregates": null, - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user group by 1 order by col asc", - "FieldQuery": "select col from user where 1 != 1 group by 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user group by 1 order by col asc", + "Table": "user" + } + ] } } @@ -1050,23 +914,25 @@ { "Original": "select count(*) from user order by null", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select count(*) from user", - "FieldQuery": "select count(*) from user where 1 != 1", - "Table": "user" - } + ] } } @@ -1079,41 +945,25 @@ { "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1, 2, 3", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(4)", + "Distinct": "false", + "GroupBy": "0, 1, 2", + "Inputs": [ { - "Opcode": "count", - "Col": 4 - } - ], - "Keys": [ - 0, - 1, - 2 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1 asc, 2 asc, 3 asc", - "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 1, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 2, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1 asc, 2 asc, 3 asc", + "Table": "user" + } + ] } } @@ -1122,41 +972,25 @@ { "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a, b, c", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(4)", + "Distinct": "false", + "GroupBy": "0, 1, 2", + "Inputs": [ { - "Opcode": "count", - "Col": 4 - } - ], - "Keys": [ - 0, - 1, - 2 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a asc, b asc, c asc", - "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 1, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 2, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a asc, b asc, c asc", + "Table": "user" + } + ] } } @@ -1165,46 +999,25 @@ { "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d, b, a, c", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(4)", + "Distinct": "false", + "GroupBy": "0, 1, 2, 3", + "Inputs": [ { - "Opcode": "count", - "Col": 4 - } - ], - "Keys": [ - 0, - 1, - 2, - 3 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d asc, b asc, a asc, c asc", - "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3, 4", - "OrderBy": [ - { - "Col": 3, - "Desc": false - }, - { - "Col": 1, - "Desc": false - }, - { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 2, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d asc, b asc, a asc, c asc", + "Table": "user" + } + ] } } @@ -1213,46 +1026,25 @@ { "Original": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d, b, a, c", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(4)", + "Distinct": "false", + "GroupBy": "2, 1, 0, 3", + "Inputs": [ { - "Opcode": "count", - "Col": 4 - } - ], - "Keys": [ - 2, - 1, - 0, - 3 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d asc, b asc, a asc, c asc", - "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 3, 2, 1, 4", - "OrderBy": [ - { - "Col": 3, - "Desc": false - }, - { - "Col": 1, - "Desc": false - }, - { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 2, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d asc, b asc, a asc, c asc", + "Table": "user" + } + ] } } @@ -1261,41 +1053,25 @@ { "Original": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(3)", + "Distinct": "false", + "GroupBy": "2, 1, 0", + "Inputs": [ { - "Opcode": "count", - "Col": 3 - } - ], - "Keys": [ - 2, - 1, - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b asc", - "FieldQuery": "select a, b, c, count(*) from user where 1 != 1 group by 3, 2, 1", - "OrderBy": [ - { - "Col": 0, - "Desc": true - }, - { - "Col": 2, - "Desc": true + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true }, - { - "Col": 1, - "Desc": false - } - ], - "Table": "user" - } + "TargetTabletType": "MASTER", + "Query": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b asc", + "Table": "user" + } + ] } } @@ -1308,36 +1084,33 @@ { "Original": "select col, count(*) from user group by col limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 1 - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col, count(*) from user group by col order by col asc limit :__upper_limit", - "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", - "OrderBy": [ + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col, count(*) from user group by col order by col asc limit :__upper_limit", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -1346,17 +1119,14 @@ { "Original": "select user.col1 as a from user where user.id = 5 group by a collate utf8_general_ci", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col1 as a from user where user.id = 5 group by a collate utf8_general_ci", - "FieldQuery": "select user.col1 as a from user where 1 != 1 group by a collate utf8_general_ci", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1366,13 +1136,13 @@ { "Original": "select id, count(*) from route2 group by id", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select id, count(*) from unsharded as route2 group by id", - "FieldQuery": "select id, count(*) from unsharded as route2 where 1 != 1 group by id", "Table": "unsharded" } } @@ -1382,13 +1152,13 @@ { "Original": "select distinct id, a from route2", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select distinct id, a from unsharded as route2", - "FieldQuery": "select id, a from unsharded as route2 where 1 != 1", "Table": "unsharded" } } @@ -1398,13 +1168,13 @@ { "Original": "select col from ref order by col", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select col from ref order by col asc", - "FieldQuery": "select col from ref where 1 != 1", "Table": "ref" } } diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt index e68e934d78a..680b157b801 100644 --- a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt @@ -3,14 +3,15 @@ { "Original": "select count(*), col from unsharded", "Instructions": { - "Opcode": "Send", + "OperatorType": "Send", + "Variant": "", "Keyspace": { "Name": "main", "Sharded": false }, - "TargetDestination": "-80", + "TargetDestination": "Shard(-80)", "Query": "select count(*), col from unsharded", - "NoAutoCommit": true + "Table": "" } } @@ -19,14 +20,15 @@ { "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { - "Opcode": "Send", + "OperatorType": "Send", + "Variant": "", "Keyspace": { "Name": "main", "Sharded": false }, - "TargetDestination": "-80", + "TargetDestination": "Shard(-80)", "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1", - "NoAutoCommit": false + "Table": "" } } @@ -35,14 +37,15 @@ { "Original": "DELETE FROM USER WHERE ID = 42", "Instructions": { - "Opcode": "Send", + "OperatorType": "Send", + "Variant": "", "Keyspace": { "Name": "main", "Sharded": false }, - "TargetDestination": "-80", + "TargetDestination": "Shard(-80)", "Query": "delete from USER where ID = 42", - "NoAutoCommit": false + "Table": "" } } @@ -51,13 +54,14 @@ { "Original": "INSERT INTO USER (ID, NAME) VALUES (42, 'ms X')", "Instructions": { - "Opcode": "Send", + "OperatorType": "Send", + "Variant": "", "Keyspace": { "Name": "main", "Sharded": false }, - "TargetDestination": "-80", + "TargetDestination": "Shard(-80)", "Query": "insert into USER(ID, NAME) values (42, 'ms X')", - "NoAutoCommit": false + "Table": "" } } diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt index 206c14014ff..a6b58289fd2 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt @@ -11,12 +11,16 @@ { "Original": "update main.m1 set val = 1", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update m1 set val = 1" + "TargetTabletType": "MASTER", + "Query": "update m1 set val = 1", + "TableName": "", + "Vindexes": "" } } @@ -25,12 +29,16 @@ { "Original": "update unsharded set val = 1", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded set val = 1" + "TargetTabletType": "MASTER", + "Query": "update unsharded set val = 1", + "TableName": "", + "Vindexes": "" } } @@ -39,12 +47,16 @@ { "Original": "update unsharded set col = (select col from unsharded limit 1)", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded set col = (select col from unsharded limit 1)" + "TargetTabletType": "MASTER", + "Query": "update unsharded set col = (select col from unsharded limit 1)", + "TableName": "", + "Vindexes": "" } } @@ -53,12 +65,16 @@ { "Original": "update unsharded set col = (select id from unsharded union select id from unsharded)", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded set col = (select id from unsharded union select id from unsharded)" + "TargetTabletType": "MASTER", + "Query": "update unsharded set col = (select id from unsharded union select id from unsharded)", + "TableName": "", + "Vindexes": "" } } @@ -67,12 +83,16 @@ { "Original": "update unsharded set col = (select id from unsharded a join unsharded b on a.id = b.id)", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded set col = (select id from unsharded as a join unsharded as b on a.id = b.id)" + "TargetTabletType": "MASTER", + "Query": "update unsharded set col = (select id from unsharded as a join unsharded as b on a.id = b.id)", + "TableName": "", + "Vindexes": "" } } @@ -81,12 +101,16 @@ { "Original": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000" + "TargetTabletType": "MASTER", + "Query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000", + "TableName": "", + "Vindexes": "" } } @@ -95,17 +119,16 @@ { "Original": "update route1 set a=1 where id=1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user as route1 set a = 1 where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -114,12 +137,16 @@ { "Original": "update unsharded_a set a=(select a from route2)", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded_a set a = (select a from unsharded as route2)" + "TargetTabletType": "MASTER", + "Query": "update unsharded_a set a = (select a from unsharded as route2)", + "TableName": "", + "Vindexes": "" } } @@ -128,12 +155,15 @@ { "Original": "delete from unsharded", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete from unsharded" + "TargetTabletType": "MASTER", + "Query": "delete from unsharded", + "TableName": "" } } @@ -142,17 +172,16 @@ { "Original": "update user set val = 1 where id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -161,17 +190,16 @@ { "Original": "update user as user_alias set val = 1 where user_alias.id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user as user_alias set val = 1 where user_alias.id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -180,17 +208,16 @@ { "Original": "update user set val = 1 where (id = 1)", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -199,17 +226,16 @@ { "Original": "update user set val = 1 where (name = 'foo' and id = 1)", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1 where name = 'foo' and id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -218,24 +244,16 @@ { "Original": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "email_user_map": { - "email": "juan@vitess.io" - } - }, - "Table": "user_metadata", - "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 for update", - "KsidVindex": "user_index" + "TableName": "user_metadata", + "Vindexes": "email_user_map" } } @@ -248,27 +266,16 @@ { "Original": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "address_user_map": { - "address": "155 5th street" - }, - "email_user_map": { - "email": "juan@vitess.io" - } - }, - "Table": "user_metadata", - "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 for update", - "KsidVindex": "user_index" + "TableName": "user_metadata", + "Vindexes": "address_user_map, email_user_map" } } @@ -277,24 +284,16 @@ { "Original": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", - "Vindex": "user_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "email_user_map": { - "email": "juan@vitess.io" - } - }, - "Table": "user_metadata", - "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 order by user_id asc limit 10 for update", - "KsidVindex": "user_index" + "TableName": "user_metadata", + "Vindexes": "email_user_map" } } @@ -303,17 +302,16 @@ { "Original": "update user set val = 1 where id = id2 and id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = id2 and id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -322,17 +320,16 @@ { "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -341,19 +338,15 @@ { "Original": "delete from user where id = 1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -362,12 +355,15 @@ { "Original": "delete a from unsharded_a a, unsharded_b b where a.id = b.id and b.val = 1", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete a from unsharded_a as a, unsharded_b as b where a.id = b.id and b.val = 1" + "TargetTabletType": "MASTER", + "Query": "delete a from unsharded_a as a, unsharded_b as b where a.id = b.id and b.val = 1", + "TableName": "" } } @@ -376,12 +372,15 @@ { "Original": "delete a from unsharded_a a join unsharded_b b on a.id = b.id where b.val = 1", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete a from unsharded_a as a join unsharded_b as b on a.id = b.id where b.val = 1" + "TargetTabletType": "MASTER", + "Query": "delete a from unsharded_a as a join unsharded_b as b on a.id = b.id where b.val = 1", + "TableName": "" } } @@ -390,12 +389,15 @@ { "Original": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000" + "TargetTabletType": "MASTER", + "Query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000", + "TableName": "" } } @@ -404,19 +406,15 @@ { "Original": "delete from route1 where id = 1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user as route1 where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -425,12 +423,15 @@ { "Original": "delete from unsharded_a where a=(select a from route2)", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete from unsharded_a where a = (select a from unsharded as route2)" + "TargetTabletType": "MASTER", + "Query": "delete from unsharded_a where a = (select a from unsharded as route2)", + "TableName": "" } } @@ -439,17 +440,16 @@ { "Original": "update music set val = 1 where id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update music set val = 1 where id = 1", - "Vindex": "music_user_map", - "Values": [ - 1 - ], - "Table": "music" + "TableName": "music", + "Vindexes": "" } } @@ -458,12 +458,16 @@ { "Original": "update unsharded_a a join unsharded_b b on a.id = b.id set a.val = 'foo' where b.val = 1", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded_a as a join unsharded_b as b on a.id = b.id set a.val = 'foo' where b.val = 1" + "TargetTabletType": "MASTER", + "Query": "update unsharded_a as a join unsharded_b as b on a.id = b.id set a.val = 'foo' where b.val = 1", + "TableName": "", + "Vindexes": "" } } @@ -472,12 +476,16 @@ { "Original": "update unsharded_a a, unsharded_b b set a.val = 'foo' where a.id = b.id and b.val = 1", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded_a as a, unsharded_b as b set a.val = 'foo' where a.id = b.id and b.val = 1" + "TargetTabletType": "MASTER", + "Query": "update unsharded_a as a, unsharded_b as b set a.val = 'foo' where a.id = b.id and b.val = 1", + "TableName": "", + "Vindexes": "" } } @@ -486,19 +494,15 @@ { "Original": "delete from music where id = 1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from music where id = 1", - "Vindex": "music_user_map", - "Values": [ - 1 - ], - "Table": "music", - "OwnedVindexQuery": "select user_id, id from music where id = 1 for update", - "KsidVindex": "user_index" + "TableName": "music" } } @@ -507,17 +511,15 @@ { "Original": "delete from music_extra where user_id = 1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from music_extra where user_id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "music_extra" + "TableName": "music_extra" } } @@ -526,13 +528,17 @@ { "Original": "insert into unsharded values()", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded values ()", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -541,13 +547,17 @@ { "Original": "insert into unsharded values(1, 2)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded values (1, 2)", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -556,13 +566,17 @@ { "Original": "insert into unsharded values(1, 2) on duplicate key update x = 3", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded values (1, 2) on duplicate key update x = 3", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -571,23 +585,17 @@ { "Original": "insert into unsharded_authoritative values(1,1)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded_authoritative(col1, col2) values (:__seq0, 1)", - "Table": "unsharded_authoritative", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_authoritative" } } @@ -596,30 +604,17 @@ { "Original": "insert into music(user_id, id) values(1, 2) on duplicate key update user_id = values(user_id)", "Instructions": { - "Opcode": "InsertShardedIgnore", + "OperatorType": "Insert", + "Variant": "ShardedIgnore", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into music(user_id, id) values (:_user_id0, :_id0) on duplicate key update user_id = values(user_id)", - "Values": [ - [ - [ - 1 - ] - ], - [ - [ - 2 - ] - ] - ], - "Table": "music", - "Prefix": "insert into music(user_id, id) values ", - "Mid": [ - "(:_user_id0, :_id0)" - ], - "Suffix": " on duplicate key update user_id = values(user_id)" + "QueryTimeout": "0", + "TableName": "music" } } @@ -628,33 +623,17 @@ { "Original": "insert into music(user_id, id) values (1, 2), (3,4) on duplicate key update user_id = values(user_id)", "Instructions": { - "Opcode": "InsertShardedIgnore", + "OperatorType": "Insert", + "Variant": "ShardedIgnore", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into music(user_id, id) values (:_user_id0, :_id0), (:_user_id1, :_id1) on duplicate key update user_id = values(user_id)", - "Values": [ - [ - [ - 1, - 3 - ] - ], - [ - [ - 2, - 4 - ] - ] - ], - "Table": "music", - "Prefix": "insert into music(user_id, id) values ", - "Mid": [ - "(:_user_id0, :_id0)", - "(:_user_id1, :_id1)" - ], - "Suffix": " on duplicate key update user_id = values(user_id)" + "QueryTimeout": "0", + "TableName": "music" } } @@ -663,13 +642,17 @@ { "Original": "insert into unsharded select id from unsharded_auto", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded select id from unsharded_auto", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -678,13 +661,17 @@ { "Original": "insert into unsharded select id from unsharded join unsharded_auto", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded select id from unsharded join unsharded_auto", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -697,23 +684,17 @@ { "Original": "insert into unsharded_auto(id, val) values(1, 'aa')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa')", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -722,23 +703,17 @@ { "Original": "insert into unsharded_auto(val) values('aa')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded_auto(val, id) values ('aa', :__seq0)", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -747,23 +722,17 @@ { "Original": "insert into unsharded_auto(val) values(false)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded_auto(val, id) values (false, :__seq0)", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -772,24 +741,17 @@ { "Original": "insert into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1, - null - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -798,13 +760,17 @@ { "Original": "insert into unsharded values((select 1 from dual), 1)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded values ((select 1 from dual), 1)", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -813,44 +779,17 @@ { "Original": "insert into route1(id) values (1)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - }, - "Prefix": "insert into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -863,24 +802,17 @@ { "Original": "insert into authoritative values(1, 2, 3)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into authoritative(user_id, col1, col2) values (:_user_id0, 2, 3)", - "Values": [ - [ - [ - 1 - ] - ] - ], - "Table": "authoritative", - "Prefix": "insert into authoritative(user_id, col1, col2) values ", - "Mid": [ - "(:_user_id0, 2, 3)" - ] + "QueryTimeout": "0", + "TableName": "authoritative" } } @@ -893,44 +825,17 @@ { "Original": "insert into user(id) values (1)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - }, - "Prefix": "insert into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -939,44 +844,17 @@ { "Original": "insert ignore into user(id) values (1)", "Instructions": { - "Opcode": "InsertShardedIgnore", + "OperatorType": "Insert", + "Variant": "ShardedIgnore", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert ignore into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - }, - "Prefix": "insert ignore into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -985,45 +863,17 @@ { "Original": "insert into user(id) values(1) on duplicate key update col = 2", "Instructions": { - "Opcode": "InsertShardedIgnore", + "OperatorType": "Insert", + "Variant": "ShardedIgnore", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0) on duplicate key update col = 2", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - }, - "Prefix": "insert into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)" - ], - "Suffix": " on duplicate key update col = 2" + "QueryTimeout": "0", + "TableName": "user" } } @@ -1032,44 +882,17 @@ { "Original": "insert into user(id) values (:aa)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - ":aa" - ] - }, - "Prefix": "insert into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1078,44 +901,17 @@ { "Original": "insert into user(nonid) values (2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(nonid, id, Name, Costly) values (2, :_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - }, - "Prefix": "insert into user(nonid, id, Name, Costly) values ", - "Mid": [ - "(2, :_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1124,44 +920,17 @@ { "Original": "insert into user(id, nonid) values (default, 2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, nonid, Name, Costly) values (:_Id0, 2, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - }, - "Prefix": "insert into user(id, nonid, Name, Costly) values ", - "Mid": [ - "(:_Id0, 2, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1170,44 +939,17 @@ { "Original": "insert into user(nonid) values (true)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(nonid, id, Name, Costly) values (true, :_Id0, :_Name0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - null - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - }, - "Prefix": "insert into user(nonid, id, Name, Costly) values ", - "Mid": [ - "(true, :_Id0, :_Name0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1216,44 +958,17 @@ { "Original": "insert into user(nonid, name, id) values (2, 'foo', 1)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(nonid, name, id, Costly) values (2, :_Name0, :_Id0, :_Costly0)", - "Values": [ - [ - [ - ":__seq0" - ] - ], - [ - [ - "foo" - ] - ], - [ - [ - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - }, - "Prefix": "insert into user(nonid, name, id, Costly) values ", - "Mid": [ - "(2, :_Name0, :_Id0, :_Costly0)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1262,34 +977,17 @@ { "Original": "insert into user_extra(nonid) values (2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user_extra(nonid, extra_id, user_id) values (2, :__seq0, :_user_id0)", - "Values": [ - [ - [ - null - ] - ] - ], - "Table": "user_extra", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - }, - "Prefix": "insert into user_extra(nonid, extra_id, user_id) values ", - "Mid": [ - "(2, :__seq0, :_user_id0)" - ] + "QueryTimeout": "0", + "TableName": "user_extra" } } @@ -1298,24 +996,17 @@ { "Original": "insert into `weird``name`(`a``b*c`, `b*c`) values(1, 2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into `weird``name`(`a``b*c`, `b*c`) values (:_a_b_c0, 2)", - "Values": [ - [ - [ - 1 - ] - ] - ], - "Table": "weird`name", - "Prefix": "insert into `weird``name`(`a``b*c`, `b*c`) values ", - "Mid": [ - "(:_a_b_c0, 2)" - ] + "QueryTimeout": "0", + "TableName": "weird`name" } } @@ -1324,13 +1015,17 @@ { "Original": "insert into unsharded select 1 from dual union select 1 from dual", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded select 1 from dual union select 1 from dual", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -1355,49 +1050,17 @@ { "Original": "insert into user(id) values (1), (2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "Values": [ - [ - [ - ":__seq0", - ":__seq1" - ] - ], - [ - [ - null, - null - ] - ], - [ - [ - null, - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1, - 2 - ] - }, - "Prefix": "insert into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)", - "(:_Id1, :_Name1, :_Costly1)" - ] + "QueryTimeout": "0", + "TableName": "user" } } @@ -1406,50 +1069,17 @@ { "Original": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id) values (1), (2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "Values": [ - [ - [ - ":__seq0", - ":__seq1" - ] - ], - [ - [ - null, - null - ] - ], - [ - [ - null, - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1, - 2 - ] - }, - "Prefix": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)", - "(:_Id1, :_Name1, :_Costly1)" - ], - "QueryTimeout": 1 + "QueryTimeout": "1", + "TableName": "user" } } @@ -1458,50 +1088,17 @@ { "Original": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id) values (1), (2)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "true", "Query": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "Values": [ - [ - [ - ":__seq0", - ":__seq1" - ] - ], - [ - [ - null, - null - ] - ], - [ - [ - null, - null - ] - ] - ], - "Table": "user", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1, - 2 - ] - }, - "Prefix": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values ", - "Mid": [ - "(:_Id0, :_Name0, :_Costly0)", - "(:_Id1, :_Name1, :_Costly1)" - ], - "MultiShardAutocommit": true + "QueryTimeout": "0", + "TableName": "user" } } @@ -1514,13 +1111,17 @@ { "Original": "replace into unsharded values(1, 2)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "replace into unsharded values (1, 2)", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -1529,13 +1130,17 @@ { "Original": "replace into unsharded select id from unsharded_auto", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "replace into unsharded select id from unsharded_auto", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -1548,23 +1153,17 @@ { "Original": "replace into unsharded_auto(id, val) values(1, 'aa')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa')", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1 - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -1573,23 +1172,17 @@ { "Original": "replace into unsharded_auto(val) values('aa')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "replace into unsharded_auto(val, id) values ('aa', :__seq0)", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - null - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -1598,24 +1191,17 @@ { "Original": "replace into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "Table": "unsharded_auto", - "Generate": { - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select next :n values from seq", - "Values": [ - 1, - null - ] - } + "QueryTimeout": "0", + "TableName": "unsharded_auto" } } @@ -1628,37 +1214,17 @@ { "Original": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0)", - "Values": [ - [ - [ - 4 - ] - ], - [ - [ - 1 - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - "Table": "multicolvin", - "Prefix": "insert into multicolvin(column_a, column_b, column_c, kid) values ", - "Mid": [ - "(:_column_a0, :_column_b0, :_column_c0, :_kid0)" - ] + "QueryTimeout": "0", + "TableName": "multicolvin" } } @@ -1667,32 +1233,17 @@ { "Original": "insert overlap_vindex (kid, column_a, column_b) VALUES (1,2,3)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into overlap_vindex(kid, column_a, column_b) values (:_kid0, :_column_a0, 3)", - "Values": [ - [ - [ - 1 - ] - ], - [ - [ - 2 - ], - [ - 1 - ] - ] - ], - "Table": "overlap_vindex", - "Prefix": "insert into overlap_vindex(kid, column_a, column_b) values ", - "Mid": [ - "(:_kid0, :_column_a0, 3)" - ] + "QueryTimeout": "0", + "TableName": "overlap_vindex" } } @@ -1701,42 +1252,17 @@ { "Original": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4), (5,6,7,8)", "Instructions": { - "Opcode": "InsertSharded", + "OperatorType": "Insert", + "Variant": "Sharded", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0), (:_column_a1, :_column_b1, :_column_c1, :_kid1)", - "Values": [ - [ - [ - 4, - 8 - ] - ], - [ - [ - 1, - 5 - ] - ], - [ - [ - 2, - 6 - ], - [ - 3, - 7 - ] - ] - ], - "Table": "multicolvin", - "Prefix": "insert into multicolvin(column_a, column_b, column_c, kid) values ", - "Mid": [ - "(:_column_a0, :_column_b0, :_column_c0, :_kid0)", - "(:_column_a1, :_column_b1, :_column_c1, :_kid1)" - ] + "QueryTimeout": "0", + "TableName": "multicolvin" } } @@ -1745,19 +1271,15 @@ { "Original": "delete from multicolvin where kid=1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from multicolvin where kid = 1", - "Vindex": "kid_index", - "Values": [ - 1 - ], - "Table": "multicolvin", - "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", - "KsidVindex": "kid_index" + "TableName": "multicolvin" } } @@ -1766,25 +1288,16 @@ { "Original": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", - "Vindex": "kid_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "colb_colc_map": { - "column_b": 1, - "column_c": 2 - } - }, - "Table": "multicolvin", - "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", - "KsidVindex": "kid_index" + "TableName": "multicolvin", + "Vindexes": "colb_colc_map" } } @@ -1793,28 +1306,16 @@ { "Original": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", - "Vindex": "kid_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "cola_map": { - "column_a": 0 - }, - "colb_colc_map": { - "column_b": 1, - "column_c": 2 - } - }, - "Table": "multicolvin", - "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", - "KsidVindex": "kid_index" + "TableName": "multicolvin", + "Vindexes": "cola_map, colb_colc_map" } } @@ -1823,13 +1324,16 @@ { "Original": "update user_extra set val = 1", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1838,13 +1342,16 @@ { "Original": "update `user[-]`.user_extra set val = 1", "Instructions": { - "Opcode": "UpdateByDestination", + "OperatorType": "Update", + "Variant": "ByDestination", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1853,14 +1360,16 @@ { "Original": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", - "Table": "user_extra", - "MultiShardAutocommit": true + "TableName": "user_extra", + "Vindexes": "" } } @@ -1869,14 +1378,16 @@ { "Original": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", - "Table": "user_extra", - "QueryTimeout": 1 + "TableName": "user_extra", + "Vindexes": "" } } @@ -1885,13 +1396,16 @@ { "Original": "update user_extra set val = 1 where id between 1 and 2", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where id between 1 and 2", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1900,13 +1414,16 @@ { "Original": "update user_extra set val = 1 where user_id in (1, 2)", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where user_id in (1, 2)", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1915,13 +1432,16 @@ { "Original": "update user_extra set val = 1 where name = 'foo'", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where name = 'foo'", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1930,13 +1450,16 @@ { "Original": "update user_extra set val = 1 where id in (1, 2)", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where id in (1, 2)", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1945,13 +1468,16 @@ { "Original": "update user_extra set val = 1 where (name = 'foo' or id = 1)", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where name = 'foo' or id = 1", - "Table": "user_extra" + "TableName": "user_extra", + "Vindexes": "" } } @@ -1960,13 +1486,15 @@ { "Original": "delete from user_extra", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user_extra", - "Table": "user_extra" + "TableName": "user_extra" } } @@ -1975,13 +1503,15 @@ { "Original": "delete from `user[-]`.user_extra", "Instructions": { - "Opcode": "DeleteByDestination", + "OperatorType": "Delete", + "Variant": "ByDestination", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user_extra", - "Table": "user_extra" + "TableName": "user_extra" } } @@ -1990,13 +1520,15 @@ { "Original": "delete from user_extra where user_id between 1 and 2", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user_extra where user_id between 1 and 2", - "Table": "user_extra" + "TableName": "user_extra" } } @@ -2005,13 +1537,15 @@ { "Original": "delete from user_extra where name = 'jose'", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user_extra where name = 'jose'", - "Table": "user_extra" + "TableName": "user_extra" } } @@ -2020,14 +1554,15 @@ { "Original": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'", - "Table": "user_extra", - "MultiShardAutocommit": true + "TableName": "user_extra" } } @@ -2036,14 +1571,15 @@ { "Original": "delete /*vt+ QUERY_TIMEOUT_MS=1 */ from user_extra where name = 'jose'", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete /*vt+ QUERY_TIMEOUT_MS=1 */ from user_extra where name = 'jose'", - "Table": "user_extra", - "QueryTimeout": 1 + "TableName": "user_extra" } } @@ -2052,13 +1588,15 @@ { "Original": "delete from user_extra where user_id in (1, 2)", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user_extra where user_id in (1, 2)", - "Table": "user_extra" + "TableName": "user_extra" } } @@ -2067,12 +1605,16 @@ { "Original": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)", "Instructions": { - "Opcode": "UpdateUnsharded", + "OperatorType": "Update", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)" + "TargetTabletType": "MASTER", + "Query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)", + "TableName": "", + "Vindexes": "" } } @@ -2081,12 +1623,15 @@ { "Original": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)", "Instructions": { - "Opcode": "DeleteUnsharded", + "OperatorType": "Delete", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)" + "TargetTabletType": "MASTER", + "Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)", + "TableName": "" } } @@ -2095,24 +1640,16 @@ { "Original": "update user set name = null where id = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set name = null where id = 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "name_user_map": { - "Name": null - } - }, - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", - "KsidVindex": "user_index" + "TableName": "user", + "Vindexes": "name_user_map" } } @@ -2121,13 +1658,17 @@ { "Original": "insert into unsharded values(last_insert_id(), 2)", "Instructions": { - "Opcode": "InsertUnsharded", + "OperatorType": "Insert", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false }, + "TargetTabletType": "MASTER", + "MultiShardAutocommit": "false", "Query": "insert into unsharded values (:__lastInsertId, 2)", - "Table": "unsharded" + "QueryTimeout": "0", + "TableName": "unsharded" } } @@ -2136,20 +1677,16 @@ { "Original": "update user set name = null where id in (1, 2, 3)", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set name = null where id in (1, 2, 3)", - "ChangedVindexValues": { - "name_user_map": { - "Name": null - } - }, - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id in (1, 2, 3) for update", - "KsidVindex": "user_index" + "TableName": "user", + "Vindexes": "name_user_map" } } @@ -2158,20 +1695,16 @@ { "Original": "update user set name = null", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set name = null", - "ChangedVindexValues": { - "name_user_map": { - "Name": null - } - }, - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user for update", - "KsidVindex": "user_index" + "TableName": "user", + "Vindexes": "name_user_map" } } @@ -2180,20 +1713,16 @@ { "Original": "update user set name = null where id + 1 = 2", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set name = null where id + 1 = 2", - "ChangedVindexValues": { - "name_user_map": { - "Name": null - } - }, - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id + 1 = 2 for update", - "KsidVindex": "user_index" + "TableName": "user", + "Vindexes": "name_user_map" } } @@ -2202,15 +1731,15 @@ { "Original": "delete from user where id in (1, 2, 3)", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user where id in (1, 2, 3)", - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id in (1, 2, 3) for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -2219,15 +1748,15 @@ { "Original": "delete from user where id + 1 = 2", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user where id + 1 = 2", - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user where id + 1 = 2 for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -2236,15 +1765,15 @@ { "Original": "delete from user", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user", - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -2253,19 +1782,15 @@ { "Original": "delete music from music where id = 1", "Instructions": { - "Opcode": "DeleteEqual", + "OperatorType": "Delete", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete music from music where id = 1", - "Vindex": "music_user_map", - "Values": [ - 1 - ], - "Table": "music", - "OwnedVindexQuery": "select user_id, id from music where id = 1 for update", - "KsidVindex": "user_index" + "TableName": "music" } } @@ -2274,13 +1799,16 @@ { "Original": "update user set val = 1", "Instructions": { - "Opcode": "UpdateScatter", + "OperatorType": "Update", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update user set val = 1", - "Table": "user" + "TableName": "user", + "Vindexes": "" } } @@ -2289,15 +1817,15 @@ { "Original": "delete from user", "Instructions": { - "Opcode": "DeleteScatter", + "OperatorType": "Delete", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "delete from user", - "Table": "user", - "OwnedVindexQuery": "select Id, Name, Costly from user for update", - "KsidVindex": "user_index" + "TableName": "user" } } @@ -2306,23 +1834,15 @@ { "Original": "update multicolvin set column_c = 2 where kid = 1", "Instructions": { - "Opcode": "UpdateEqual", + "OperatorType": "Update", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "update multicolvin set column_c = 2 where kid = 1", - "Vindex": "kid_index", - "Values": [ - 1 - ], - "ChangedVindexValues": { - "colb_colc_map": { - "column_c": 2 - } - }, - "Table": "multicolvin", - "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", - "KsidVindex": "kid_index" + "TableName": "multicolvin", + "Vindexes": "colb_colc_map" } } diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt index 9a580d21701..4d755e097b3 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt @@ -3,13 +3,14 @@ { "Original": "select id from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } @@ -19,17 +20,14 @@ { "Original": "select id from user where user.id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.id = 5", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -39,13 +37,14 @@ { "Original": "select id from user where user.id = 5+5", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.id = 5 + 5", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } @@ -55,17 +54,14 @@ { "Original": "select id from music where id = 5 and user_id = 4", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from music where id = 5 and user_id = 4", - "FieldQuery": "select id from music where 1 != 1", - "Vindex": "user_index", - "Values": [ - 4 - ], "Table": "music" } } @@ -75,17 +71,14 @@ { "Original": "select id from user where costly = 'aa' and name = 'bb'", "Instructions": { - "Opcode": "SelectEqual", + "OperatorType": "Route", + "Variant": "SelectEqual", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where costly = 'aa' and name = 'bb'", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - "bb" - ], "Table": "user" } } @@ -95,20 +88,14 @@ { "Original": "select id from user where costly in ('aa', 'bb') and name in ('aa', 'bb')", "Instructions": { - "Opcode": "SelectIN", + "OperatorType": "Route", + "Variant": "SelectIN", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where costly in ('aa', 'bb') and name in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - [ - "aa", - "bb" - ] - ], "Table": "user" } } @@ -118,13 +105,14 @@ { "Original": "select id from user where name in (col, 'bb')", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where name in (col, 'bb')", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } @@ -134,17 +122,14 @@ { "Original": "select id from user where name = :a", "Instructions": { - "Opcode": "SelectEqual", + "OperatorType": "Route", + "Variant": "SelectEqual", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where name = :a", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - ":a" - ], "Table": "user" } } @@ -154,17 +139,14 @@ { "Original": "select id from user where name = 18446744073709551615", "Instructions": { - "Opcode": "SelectEqual", + "OperatorType": "Route", + "Variant": "SelectEqual", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where name = 18446744073709551615", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - 18446744073709551615 - ], "Table": "user" } } @@ -174,17 +156,14 @@ { "Original": "select id from user where name in ::list", "Instructions": { - "Opcode": "SelectIN", + "OperatorType": "Route", + "Variant": "SelectIN", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where name in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - "::list" - ], "Table": "user" } } @@ -194,17 +173,14 @@ { "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", - "FieldQuery": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -214,17 +190,14 @@ { "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", - "FieldQuery": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -234,17 +207,14 @@ { "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user.id = 5", - "FieldQuery": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -254,17 +224,14 @@ { "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", - "FieldQuery": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -274,37 +241,35 @@ { "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user where user.id = 5", - "FieldQuery": "select user.col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where user.id = 5", + "Table": "user" }, - "Query": "select user_extra.id from user_extra where user_extra.col = :user_col", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra where user_extra.col = :user_col", + "Table": "user_extra" + } + ] } } @@ -313,41 +278,35 @@ { "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5 and user_extra.user_id = 5", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user where user.id = 5", - "FieldQuery": "select user.col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where user.id = 5", + "Table": "user" }, - "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = 5", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user_extra" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = 5", + "Table": "user_extra" + } + ] } } @@ -356,37 +315,35 @@ { "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user_extra.user_id = user.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" }, - "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = :user_col", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":user_col" - ], - "Table": "user_extra" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = :user_col", + "Table": "user_extra" + } + ] } } @@ -395,33 +352,35 @@ { "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user where 1 = 1", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where 1 = 1", + "Table": "user" }, - "Query": "select user_extra.id from user_extra where user_extra.col = :user_col", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra where user_extra.col = :user_col", + "Table": "user_extra" + } + ] } } @@ -430,20 +389,14 @@ { "Original": "select id from user where user.col = 5 and user.id in (1, 2)", "Instructions": { - "Opcode": "SelectIN", + "OperatorType": "Route", + "Variant": "SelectIN", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.col = 5 and user.id in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - [ - 1, - 2 - ] - ], "Table": "user" } } @@ -453,20 +406,14 @@ { "Original": "select id from user where user.col = case user.col when 'foo' then true else false end and user.id in (1, 2)", "Instructions": { - "Opcode": "SelectIN", + "OperatorType": "Route", + "Variant": "SelectIN", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.col = case user.col when 'foo' then true else false end and user.id in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - [ - 1, - 2 - ] - ], "Table": "user" } } @@ -476,17 +423,14 @@ { "Original": "select (id or col) as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", "Instructions": { - "Opcode": "SelectEqual", + "OperatorType": "Route", + "Variant": "SelectEqual", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id or col as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", - "FieldQuery": "select id or col as val from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - "aa" - ], "Table": "user" } } @@ -496,17 +440,14 @@ { "Original": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", "Instructions": { - "Opcode": "SelectEqual", + "OperatorType": "Route", + "Variant": "SelectEqual", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - "aa" - ], "Table": "user" } } @@ -516,17 +457,14 @@ { "Original": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -536,17 +474,14 @@ { "Original": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -556,13 +491,14 @@ { "Original": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } @@ -572,33 +508,34 @@ { "Original": "select unsharded.id from user join unsharded where unsharded.id = user.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id from user", - "FieldQuery": "select user.id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id from user", + "Table": "user" }, - "Query": "select unsharded.id from unsharded where unsharded.id = :user_id", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_id": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded where unsharded.id = :user_id", + "Table": "unsharded" + } + ] } } @@ -607,17 +544,14 @@ { "Original": "select col from route1 where id = 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user as route1 where id = 1", - "FieldQuery": "select col from user as route1 where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -627,17 +561,14 @@ { "Original": "select col from route1 where email = 'aaa'", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user_metadata as route1 where email = 'aaa'", - "FieldQuery": "select col from user_metadata as route1 where 1 != 1", - "Vindex": "email_user_map", - "Values": [ - "aaa" - ], "Table": "user_metadata" } } @@ -647,13 +578,14 @@ { "Original": "select * from information_schema.a where id in (select * from information_schema.b)", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from information_schema.a where id in (select * from information_schema.b)", - "FieldQuery": "select * from information_schema.a where 1 != 1" + "Table": "" } } @@ -662,40 +594,35 @@ { "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col) and u.id in (user_extra.col, 1)", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user_extra.col from user_extra", - "FieldQuery": "select user_extra.col from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Right": { - "Opcode": "SelectIN", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_extra_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.col from user_extra", + "Table": "user_extra" }, - "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)", - "FieldQuery": "select u.m from user as u where 1 != 1", - "Vindex": "user_index", - "Values": [ - [ - ":user_extra_col", - 1 - ] - ], - "Table": "user" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_extra_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectIN", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "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" + } + ] } } @@ -704,33 +631,34 @@ { "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = 5) and u.id = 5", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_extra_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" }, - "Query": "select u.m from user as u where u.id = 5 and u.id in (select m2 from user where user.id = 5)", - "FieldQuery": "select u.m from user as u where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Cols": [ - 1 + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "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" + } ] } } @@ -740,40 +668,35 @@ { "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col and user.id in (select m3 from user_extra where user_extra.user_id = user.id)) and u.id in (user_extra.col, 1)", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user_extra.col from user_extra", - "FieldQuery": "select user_extra.col from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Right": { - "Opcode": "SelectIN", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_extra_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.col from user_extra", + "Table": "user_extra" }, - "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))", - "FieldQuery": "select u.m from user as u where 1 != 1", - "Vindex": "user_index", - "Values": [ - [ - ":user_extra_col", - 1 - ] - ], - "Table": "user" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_extra_col": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectIN", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "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" + } + ] } } @@ -782,13 +705,14 @@ { "Original": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } @@ -798,17 +722,14 @@ { "Original": "select id from user where id = 5 and user.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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)", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -818,17 +739,14 @@ { "Original": "select id from user where id = 'aa' and user.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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')", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - "aa" - ], "Table": "user" } } @@ -838,17 +756,14 @@ { "Original": "select id from user where id = :a and user.col in (select user_extra.col from user_extra where user_extra.user_id = :a)", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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)", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":a" - ], "Table": "user" } } @@ -862,13 +777,14 @@ { "Original": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id2 from user as uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", - "FieldQuery": "select id2 from user as uu where 1 != 1", "Table": "user" } } @@ -879,33 +795,33 @@ { "Original": "select id from user where id in (select col from user)", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectIN", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select id from user where :__sq_has_values1 = 1 and id in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - "::__sq1" - ], - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectIN", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user where :__sq_has_values1 = 1 and id in ::__vals", + "Table": "user" + } + ] } } @@ -914,29 +830,33 @@ { "Original": "select id from user where id not in (select col from user)", "Instructions": { - "Opcode": "PulloutNotIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutNotIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select id from user where :__sq_has_values1 = 0 or id not in ::__sq1", - "FieldQuery": "select id from user where 1 != 1", - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user where :__sq_has_values1 = 0 or id not in ::__sq1", + "Table": "user" + } + ] } } @@ -945,29 +865,33 @@ { "Original": "select id from user where exists (select col from user)", "Instructions": { - "Opcode": "PulloutExists", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutExists", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select id from user where :__sq_has_values1", - "FieldQuery": "select id from user where 1 != 1", - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user where :__sq_has_values1", + "Table": "user" + } + ] } } @@ -976,33 +900,33 @@ { "Original": "select id from user where id = (select col from user)", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select id from user where id = :__sq1", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":__sq1" - ], - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user where id = :__sq1", + "Table": "user" + } + ] } } @@ -1011,48 +935,51 @@ { "Original": "select id1 from user where id = (select id2 from user where id2 in (select id3 from user))", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq2", - "HasValues": "__sq_has_values2", - "Subquery": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select id3 from user", - "FieldQuery": "select id3 from user where 1 != 1", - "Table": "user" + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id3 from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id2 from user where :__sq_has_values1 = 1 and id2 in ::__sq1", + "Table": "user" + } + ] }, - "Underlying": { - "Opcode": "SelectScatter", + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select id2 from user where :__sq_has_values1 = 1 and id2 in ::__sq1", - "FieldQuery": "select id2 from user where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select id1 from user where id = :__sq2", "Table": "user" } - }, - "Underlying": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select id1 from user where id = :__sq2", - "FieldQuery": "select id1 from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":__sq2" - ], - "Table": "user" - } + ] } } @@ -1061,13 +988,14 @@ { "Original": "select col from user where id = (select id from route2 where route2.id = user.id)", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user where id = (select id from user as route2 where route2.id = user.id)", - "FieldQuery": "select col from user where 1 != 1", "Table": "user" } } @@ -1077,33 +1005,32 @@ { "Original": "select col from user where id = (select id from route2)", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select id from unsharded as route2", - "FieldQuery": "select id from unsharded as route2 where 1 != 1", - "Table": "unsharded" - }, - "Underlying": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select id from unsharded as route2", + "Table": "unsharded" }, - "Query": "select col from user where id = :__sq1", - "FieldQuery": "select col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":__sq1" - ], - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user where id = :__sq1", + "Table": "user" + } + ] } } @@ -1112,17 +1039,14 @@ { "Original": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", - "FieldQuery": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1132,13 +1056,14 @@ { "Original": "select id from user where database()", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from user where database()", - "FieldQuery": "select id from user where 1 != 1", "Table": "user" } } diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index d673886737c..78f5b9378dc 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -3,13 +3,14 @@ { "Original": "select col from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", "Table": "user" } } @@ -19,13 +20,13 @@ { "Original": "select col from unsharded", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select col from unsharded", - "FieldQuery": "select col from unsharded where 1 != 1", "Table": "unsharded" } } @@ -35,13 +36,13 @@ { "Original": "select next 2 values from seq", "Instructions": { - "Opcode": "SelectNext", + "OperatorType": "Route", + "Variant": "SelectNext", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select next 2 values from seq", - "FieldQuery": "select next 2 values from seq where 1 != 1", "Table": "seq" } } @@ -51,13 +52,13 @@ { "Original": "select * from ref", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select * from ref", - "FieldQuery": "select * from ref where 1 != 1", "Table": "ref" } } @@ -67,13 +68,14 @@ { "Original": "select col from information_schema.foo", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select col from information_schema.foo", - "FieldQuery": "select col from information_schema.foo where 1 != 1" + "Table": "" } } @@ -82,13 +84,13 @@ { "Original": "select m1.col from unsharded as m1 join unsharded as m2", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select m1.col from unsharded as m1 join unsharded as m2", - "FieldQuery": "select m1.col from unsharded as m1 join unsharded as m2 where 1 != 1", "Table": "unsharded" } } @@ -98,29 +100,34 @@ { "Original": "select music.col from user join music", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user", - "FieldQuery": "select 1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user", + "Table": "user" }, - "Query": "select music.col from music", - "FieldQuery": "select music.col from music where 1 != 1", - "Table": "music" - }, - "Cols": [ - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col from music", + "Table": "music" + } ] } } @@ -130,13 +137,14 @@ { "Original": "select * from second_user.user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user", - "FieldQuery": "select * from user where 1 != 1", "Table": "user" } } @@ -146,13 +154,14 @@ { "Original": "select * from second_user.user as a", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user as a", - "FieldQuery": "select * from user as a where 1 != 1", "Table": "user" } } @@ -162,13 +171,14 @@ { "Original": "select * from route1", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user as route1", - "FieldQuery": "select * from user as route1 where 1 != 1", "Table": "user" } } @@ -178,13 +188,14 @@ { "Original": "select * from route1 as a", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user as a", - "FieldQuery": "select * from user as a where 1 != 1", "Table": "user" } } @@ -194,13 +205,14 @@ { "Original": "select * from master_redirect", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user as master_redirect", - "FieldQuery": "select * from user as master_redirect where 1 != 1", "Table": "user" } } @@ -218,29 +230,34 @@ { "Original": "select music.col from user, music", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user", - "FieldQuery": "select 1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user", + "Table": "user" }, - "Query": "select music.col from music", - "FieldQuery": "select music.col from music where 1 != 1", - "Table": "music" - }, - "Cols": [ - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col from music", + "Table": "music" + } ] } } @@ -250,13 +267,13 @@ { "Original": "select u1.a, u2.a from unsharded u1, unsharded u2", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select u1.a, u2.a from unsharded as u1, unsharded as u2", - "FieldQuery": "select u1.a, u2.a from unsharded as u1, unsharded as u2 where 1 != 1", "Table": "unsharded" } } @@ -266,13 +283,14 @@ { "Original": "select * from information_schema.a, information_schema.b", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from information_schema.a, information_schema.b", - "FieldQuery": "select * from information_schema.a, information_schema.b where 1 != 1" + "Table": "" } } @@ -281,13 +299,13 @@ { "Original": "select u1.a, u2.a from unsharded u1, unsharded u2, unsharded u3", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select u1.a, u2.a from unsharded as u1, unsharded as u2, unsharded as u3", - "FieldQuery": "select u1.a, u2.a from unsharded as u1, unsharded as u2, unsharded as u3 where 1 != 1", "Table": "unsharded" } } @@ -297,13 +315,13 @@ { "Original": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a=m2.b", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a = m2.b", - "FieldQuery": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a = m2.b where 1 != 1", "Table": "unsharded" } } @@ -313,33 +331,34 @@ { "Original": "select u.col from user u left join unsharded m on u.a = m.b", "Instructions": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.col, u.a from user as u", - "FieldQuery": "select u.col, u.a from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.col, u.a from user as u", + "Table": "user" }, - "Query": "select 1 from unsharded as m where m.b = :u_a", - "FieldQuery": "select 1 from unsharded as m where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1 - ], - "Vars": { - "u_a": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded as m where m.b = :u_a", + "Table": "unsharded" + } + ] } } @@ -348,53 +367,53 @@ { "Original": "select user.col from user left join unsharded as m1 on user.col = m1.co left join unsharded as m2 on m1.col = m2.col", "Instructions": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_unsharded_unsharded", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select m1.col from unsharded as m1 where m1.co = :user_col", + "Table": "unsharded" + } + ] }, - "Right": { - "Opcode": "SelectUnsharded", + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "select m1.col from unsharded as m1 where m1.co = :user_col", - "FieldQuery": "select m1.col from unsharded as m1 where 1 != 1", + "Query": "select 1 from unsharded as m2 where m2.col = :m1_col", "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "user_col": 0 } - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from unsharded as m2 where m2.col = :m1_col", - "FieldQuery": "select 1 from unsharded as m2 where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1 - ], - "Vars": { - "m1_col": 1 - } + ] } } @@ -403,49 +422,54 @@ { "Original": "select user.col from user left join user_extra as e left join unsharded as m1 on m1.col = e.col on user.col = e.col", "Instructions": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "SelectScatter", + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select e.col from user_extra as e where e.col = :user_col", - "FieldQuery": "select e.col from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from unsharded as m1 where m1.col = :e_col", - "FieldQuery": "select 1 from unsharded as m1 where 1 != 1", - "Table": "unsharded" + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" }, - "Vars": { - "e_col": 0 + { + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "", + "TableName": "user_extra_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.col from user_extra as e where e.col = :user_col", + "Table": "user_extra" + }, + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded as m1 where m1.col = :e_col", + "Table": "unsharded" + } + ] } - }, - "Cols": [ - -1 - ], - "Vars": { - "user_col": 0 - } + ] } } @@ -454,13 +478,13 @@ { "Original": "select m1.col from unsharded as m1 right join unsharded as m2 on m1.a=m2.b", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select m1.col from unsharded as m2 left join unsharded as m1 on m1.a = m2.b", - "FieldQuery": "select m1.col from unsharded as m2 left join unsharded as m1 on m1.a = m2.b where 1 != 1", "Table": "unsharded" } } @@ -470,13 +494,13 @@ { "Original": "select m1.col from unsharded as m1 join unsharded as m2 right join unsharded as m3 on m1.a=m2.b", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select m1.col from unsharded as m3 left join (unsharded as m1 join unsharded as m2) on m1.a = m2.b", - "FieldQuery": "select m1.col from unsharded as m3 left join (unsharded as m1 join unsharded as m2) on m1.a = m2.b where 1 != 1", "Table": "unsharded" } } @@ -486,13 +510,13 @@ { "Original": "select m1.col from unsharded as m1 straight_join unsharded as m2", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select m1.col from unsharded as m1 straight_join unsharded as m2", - "FieldQuery": "select m1.col from unsharded as m1 straight_join unsharded as m2 where 1 != 1", "Table": "unsharded" } } @@ -502,45 +526,52 @@ { "Original": "select user.col from user join unsharded as m1 join unsharded as m2", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_unsharded_unsharded", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded as m1", + "Table": "unsharded" + } + ] }, - "Right": { - "Opcode": "SelectUnsharded", + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, - "Query": "select 1 from unsharded as m1", - "FieldQuery": "select 1 from unsharded as m1 where 1 != 1", + "Query": "select 1 from unsharded as m2", "Table": "unsharded" - }, - "Cols": [ - -1 - ] - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from unsharded as m2", - "FieldQuery": "select 1 from unsharded as m2 where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1 + } ] } } @@ -550,29 +581,33 @@ { "Original": "select user.col from user join (unsharded as m1 join unsharded as m2)", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" }, - "Query": "select 1 from (unsharded as m1 join unsharded as m2)", - "FieldQuery": "select 1 from (unsharded as m1 join unsharded as m2) where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from (unsharded as m1 join unsharded as m2)", + "Table": "unsharded" + } ] } } @@ -582,42 +617,53 @@ { "Original": "select user.col from user join (user as u1 join unsharded)", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user as u1", - "FieldQuery": "select 1 from user as u1 where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select user.col from user", "Table": "user" }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from unsharded", - "FieldQuery": "select 1 from unsharded where 1 != 1", - "Table": "unsharded" + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded", + "Table": "unsharded" + } + ] } - }, - "Cols": [ - -1 ] } } @@ -627,13 +673,14 @@ { "Original": "select user.col from user use index(a)", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user use index (a)", - "FieldQuery": "select user.col from user use index (a) where 1 != 1", "Table": "user" } } @@ -643,13 +690,14 @@ { "Original": "select user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", - "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Table": "user" } } @@ -659,13 +707,14 @@ { "Original": "select user.col from user join user_extra on (user.id = user_extra.user_id)", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", - "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Table": "user" } } @@ -675,13 +724,14 @@ { "Original": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", - "FieldQuery": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id where 1 != 1", "Table": "user" } } @@ -691,13 +741,14 @@ { "Original": "select user.col from user join user_extra on user_extra.user_id = user.id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user_extra.user_id = user.id", - "FieldQuery": "select user.col from user join user_extra on user_extra.user_id = user.id where 1 != 1", "Table": "user" } } @@ -707,17 +758,14 @@ { "Original": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", - "FieldQuery": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -727,33 +775,35 @@ { "Original": "select user.col from user join user_extra on user.id \u003c user_extra.user_id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col, user.id from user", - "FieldQuery": "select user.col, user.id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col, user.id from user", + "Table": "user" }, - "Query": "select 1 from user_extra where :user_id \u003c user_extra.user_id", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 - ], - "Vars": { - "user_id": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra where :user_id \u003c user_extra.user_id", + "Table": "user_extra" + } + ] } } @@ -762,33 +812,34 @@ { "Original": "select user.col from user join user_extra on user.id = 5", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user where user.id = 5", - "FieldQuery": "select user.col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where user.id = 5", + "Table": "user" }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } ] } } @@ -798,33 +849,34 @@ { "Original": "select user.col from user join user_extra on 5 = user.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user where user.id = 5", - "FieldQuery": "select user.col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where user.id = 5", + "Table": "user" }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } ] } } @@ -834,33 +886,35 @@ { "Original": "select user.col from user join user_extra on user.id = user_extra.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col, user.id from user", - "FieldQuery": "select user.col, user.id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col, user.id from user", + "Table": "user" }, - "Query": "select 1 from user_extra where user_extra.col = :user_id", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 - ], - "Vars": { - "user_id": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra where user_extra.col = :user_id", + "Table": "user_extra" + } + ] } } @@ -869,37 +923,35 @@ { "Original": "select user.col from user_extra join user on user_extra.user_id = user.name", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user_extra.user_id from user_extra", - "FieldQuery": "select user_extra.user_id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Right": { - "Opcode": "SelectEqual", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_extra_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.user_id from user_extra", + "Table": "user_extra" }, - "Query": "select user.col from user where user.name = :user_extra_user_id", - "FieldQuery": "select user.col from user where 1 != 1", - "Vindex": "name_user_map", - "Values": [ - ":user_extra_user_id" - ], - "Table": "user" - }, - "Cols": [ - 1 - ], - "Vars": { - "user_extra_user_id": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectEqual", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user where user.name = :user_extra_user_id", + "Table": "user" + } + ] } } @@ -908,13 +960,14 @@ { "Original": "select user.col from user join ref", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join ref", - "FieldQuery": "select user.col from user join ref where 1 != 1", "Table": "user" } } @@ -924,13 +977,13 @@ { "Original": "select r1.col from ref r1 join ref", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select r1.col from ref as r1 join ref", - "FieldQuery": "select r1.col from ref as r1 join ref where 1 != 1", "Table": "ref" } } @@ -940,13 +993,14 @@ { "Original": "select ref.col from ref join user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select ref.col from ref join user", - "FieldQuery": "select ref.col from ref join user where 1 != 1", "Table": "user" } } @@ -956,13 +1010,14 @@ { "Original": "select route2.col from route2 join user_extra on route2.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id", - "FieldQuery": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id where 1 != 1", "Table": "user" } } @@ -972,29 +1027,33 @@ { "Original": "select route2.col from route2 join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select route2.col from unsharded as route2", - "FieldQuery": "select route2.col from unsharded as route2 where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select route2.col from unsharded as route2", + "Table": "unsharded" }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } ] } } @@ -1004,17 +1063,14 @@ { "Original": "select id from (select id, col from user where id = 5) as t", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from (select id, col from user where id = 5) as t", - "FieldQuery": "select id from (select id, col from user where 1 != 1) as t where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1024,17 +1080,14 @@ { "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", - "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", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1044,17 +1097,14 @@ { "Original": "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", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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", - "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", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1068,13 +1118,14 @@ { "Original": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", - "FieldQuery": "select t.id from user_extra join (select id from user where 1 != 1) as t on t.id = user_extra.user_id where 1 != 1", "Table": "user_extra" } } @@ -1084,37 +1135,35 @@ { "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select t.id from (select id from user where id = 5) as t", - "FieldQuery": "select t.id from (select id from user where 1 != 1) as t where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select t.id from (select id from user where id = 5) as t", + "Table": "user" }, - "Query": "select 1 from user_extra where user_extra.col = :t_id", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 - ], - "Vars": { - "t_id": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra where user_extra.col = :t_id", + "Table": "user_extra" + } + ] } } @@ -1123,17 +1172,14 @@ { "Original": "select id from (select id, col from route1 where id = 5) as t", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from (select id, col from user as route1 where id = 5) as t", - "FieldQuery": "select id from (select id, col from user as route1 where 1 != 1) as t where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1143,17 +1189,14 @@ { "Original": "select id from (select id, col from route1 where email = 'aaa') as t", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from (select id, col from user_metadata as route1 where email = 'aaa') as t", - "FieldQuery": "select id from (select id, col from user_metadata as route1 where 1 != 1) as t where 1 != 1", - "Vindex": "email_user_map", - "Values": [ - "aaa" - ], "Table": "user_metadata" } } @@ -1163,17 +1206,14 @@ { "Original": "select id from (select id, col from route1) as t where id = 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select id from (select id, col from user as route1) as t where id = 5", - "FieldQuery": "select id from (select id, col from user as route1 where 1 != 1) as t where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1183,17 +1223,14 @@ { "Original": "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", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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", - "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", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -1203,13 +1240,14 @@ { "Original": "select * from information_schema.a where b=10", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from information_schema.a where b = 10", - "FieldQuery": "select * from information_schema.a where 1 != 1" + "Table": "" } } @@ -1218,13 +1256,14 @@ { "Original": "select * from information_schema.a where information_schema.a.b=10", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from information_schema.a where information_schema.a.b = 10", - "FieldQuery": "select * from information_schema.a where 1 != 1" + "Table": "" } } @@ -1233,28 +1272,32 @@ { "Original": "select unsharded.foo from information_schema.a join unsharded", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectDBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from information_schema.a", - "FieldQuery": "select 1 from information_schema.a where 1 != 1" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectDBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from information_schema.a", + "Table": "" }, - "Query": "select unsharded.foo from unsharded", - "FieldQuery": "select unsharded.foo from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - 1 + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.foo from unsharded", + "Table": "unsharded" + } ] } } @@ -1264,28 +1307,32 @@ { "Original": "select unsharded.foo from unsharded join information_schema.a", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select unsharded.foo from unsharded", - "FieldQuery": "select unsharded.foo from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "SelectDBA", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.foo from unsharded", + "Table": "unsharded" }, - "Query": "select 1 from information_schema.a", - "FieldQuery": "select 1 from information_schema.a where 1 != 1" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectDBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from information_schema.a", + "Table": "" + } ] } } @@ -1295,57 +1342,62 @@ { "Original": "select t.col1 from (select user.id, user.col1 from user join user_extra) as t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Cols": [ - 1, - 0 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id, user.col1 from user", - "FieldQuery": "select user.id, user.col1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - -2 + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra_unsharded", + "Inputs": [ + { + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "1, 0", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id, user.col1 from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } + ] + } ] - } - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false }, - "Query": "select 1 from unsharded where unsharded.col1 = :t_col1 and unsharded.id = :t_id", - "FieldQuery": "select 1 from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1 - ], - "Vars": { - "t_col1": 0, - "t_id": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded where unsharded.col1 = :t_col1 and unsharded.id = :t_id", + "Table": "unsharded" + } + ] } } @@ -1354,39 +1406,43 @@ { "Original": "select t.id from (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) as t", "Instructions": { - "Cols": [ - 0 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id, user.col1, user.col from user", - "FieldQuery": "select user.id, user.col1, user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra where user_extra.col = :user_col", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - -2 - ], - "Vars": { - "user_col": 2 + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "0", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id, user.col1, user.col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra where user_extra.col = :user_col", + "Table": "user_extra" + } + ] } - } + ] } } @@ -1395,51 +1451,61 @@ { "Original": "select t.col1 from unsharded_a ua join (select user.id, user.col1 from user join user_extra) as t", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select 1 from unsharded_a as ua", - "FieldQuery": "select 1 from unsharded_a as ua where 1 != 1", - "Table": "unsharded_a" - }, - "Right": { - "Cols": [ - 1 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id, user.col1 from user", - "FieldQuery": "select user.id, user.col1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "unsharded_a_user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false }, - "Cols": [ - -1, - -2 + "Query": "select 1 from unsharded_a as ua", + "Table": "unsharded_a" + }, + { + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "1", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id, user.col1 from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } + ] + } ] } - }, - "Cols": [ - 1 ] } } @@ -1449,29 +1515,32 @@ { "Original": "select unsharded_a.col from unsharded_a join unsharded_b on (select col from user)", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq1", - "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq1 where 1 != 1", - "Table": "unsharded_a" - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq1", + "Table": "unsharded_a" + } + ] } } @@ -1480,29 +1549,32 @@ { "Original": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col+(select col from user)", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col + :__sq1", - "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col + :__sq1 where 1 != 1", - "Table": "unsharded_a" - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col + :__sq1", + "Table": "unsharded_a" + } + ] } } @@ -1511,29 +1583,32 @@ { "Original": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col in (select col from user)", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq_has_values1 = 1 and unsharded_a.col in ::__sq1", - "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq_has_values1 = 1 and unsharded_a.col in ::__sq1 where 1 != 1", - "Table": "unsharded_a" - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq_has_values1 = 1 and unsharded_a.col in ::__sq1", + "Table": "unsharded_a" + } + ] } } @@ -1542,45 +1617,52 @@ { "Original": "select unsharded.col from unsharded join user on user.col in (select col from user)", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select unsharded.col from unsharded", - "FieldQuery": "select unsharded.col from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "SelectScatter", + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", - "FieldQuery": "select 1 from user where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select col from user", "Table": "user" }, - "Cols": [ - -1 - ] - } + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.col from unsharded", + "Table": "unsharded" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", + "Table": "user" + } + ] + } + ] } } @@ -1590,44 +1672,51 @@ { "Original": "select unsharded.col from unsharded left join user on user.col in (select col from user)", "Instructions": { - "Opcode": "LeftJoin", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select unsharded.col from unsharded", - "FieldQuery": "select unsharded.col from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", + "OperatorType": "Join", + "Variant": "LeftJoin", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { - "Name": "user", - "Sharded": true + "Name": "main", + "Sharded": false }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" + "Query": "select unsharded.col from unsharded", + "Table": "unsharded" }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", - "FieldQuery": "select 1 from user where 1 != 1", - "Table": "user" + { + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", + "Table": "user" + } + ] } - }, - "Cols": [ - -1 ] } } @@ -1638,60 +1727,70 @@ { "Original": "select unsharded.col from unsharded join user on user.col in (select col from user) join unsharded_a", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_user_unsharded_a", + "Inputs": [ + { + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select unsharded.col from unsharded", - "FieldQuery": "select unsharded.col from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", - "FieldQuery": "select 1 from user where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1 + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "unsharded_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.col from unsharded", + "Table": "unsharded" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", + "Table": "user" + } + ] + } ] - } - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false }, - "Query": "select 1 from unsharded_a", - "FieldQuery": "select 1 from unsharded_a where 1 != 1", - "Table": "unsharded_a" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select 1 from unsharded_a", + "Table": "unsharded_a" + } ] } } @@ -1701,34 +1800,34 @@ { "Original": "select user.user.col1, main.unsharded.col1 from user.user join main.unsharded where main.unsharded.col2 = user.user.col2", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1, user.col2 from user", - "FieldQuery": "select user.col1, user.col2 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1, user.col2 from user", + "Table": "user" }, - "Query": "select unsharded.col1 from unsharded where unsharded.col2 = :user_col2", - "FieldQuery": "select unsharded.col1 from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "user_col2": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.col1 from unsharded where unsharded.col2 = :user_col2", + "Table": "unsharded" + } + ] } } @@ -1737,13 +1836,13 @@ { "Original": "select main.foo.col from main.foo", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select foo.col from foo", - "FieldQuery": "select foo.col from foo where 1 != 1", "Table": "foo" } } @@ -1753,13 +1852,14 @@ { "Original": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col from user join user_extra on user.ID = user_extra.User_Id", - "FieldQuery": "select user.col from user join user_extra on user.ID = user_extra.User_Id where 1 != 1", "Table": "user" } } @@ -1769,36 +1869,43 @@ { "Original": "select id, t.id from (select user.id from user join user_extra) as t", "Instructions": { - "Cols": [ - 0, - 0 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id from user", - "FieldQuery": "select user.id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 - ] - } + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "0, 0", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } + ] + } + ] } } @@ -1808,13 +1915,13 @@ { "Original": "select u1.a from unsharded u1 join unsharded u2 on database()", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select u1.a from unsharded as u1 join unsharded as u2 on database()", - "FieldQuery": "select u1.a from unsharded as u1 join unsharded as u2 on database() where 1 != 1", "Table": "unsharded" } } @@ -1824,13 +1931,13 @@ { "Original": "select last_insert_id()", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select :__lastInsertId as `last_insert_id()` from dual", - "FieldQuery": "select :__lastInsertId as `last_insert_id()` from dual where 1 != 1", "Table": "dual" } } @@ -1840,13 +1947,14 @@ { "Original": "select last_insert_id() from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select :__lastInsertId as `last_insert_id()` from user", - "FieldQuery": "select :__lastInsertId as `last_insert_id()` from user where 1 != 1", "Table": "user" } } @@ -1856,13 +1964,13 @@ { "Original": "select last_insert_id() from main.unsharded", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select :__lastInsertId as `last_insert_id()` from unsharded", - "FieldQuery": "select :__lastInsertId as `last_insert_id()` from unsharded where 1 != 1", "Table": "unsharded" } } diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt index 8947e10666d..b99145e3781 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt @@ -4,41 +4,33 @@ { "Original": "select a, b, count(*) from user group by a order by b", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "1 ASC", + "Inputs": [ { - "Col": 1, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) from user group by a order by a asc", - "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by a", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) from user group by a order by a asc", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -47,41 +39,33 @@ { "Original": "select a, b, count(*) k from user group by a order by k", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "2 ASC", + "Inputs": [ { - "Col": 2, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) as k from user group by a order by a asc", - "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) as k from user group by a order by a asc", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -90,49 +74,33 @@ { "Original": "select a, b, count(*) k from user group by a order by b, a, k", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "1 ASC, 0 ASC, 2 ASC", + "Inputs": [ { - "Col": 1, - "Desc": false - }, - { - "Col": 0, - "Desc": false - }, - { - "Col": 2, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) as k from user group by a order by a asc", - "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) as k from user group by a order by a asc", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -141,46 +109,41 @@ { "Original": "select a, b, count(*) k from user group by a order by k desc limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "MemorySort", - "MaxRows": ":__upper_limit", - "OrderBy": [ - { - "Col": 2, - "Desc": true - } - ], - "Input": { - "Aggregates": [ + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "2 DESC", + "Inputs": [ { - "Opcode": "count", - "Col": 2 + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) as k from user group by a order by a asc", + "Table": "user" + } + ] } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) as k from user group by a order by a asc", - "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + ] } - } + ] } } @@ -189,45 +152,33 @@ { "Original": "select a, b, count(*) k from user group by a order by 1,3", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "0 ASC, 2 ASC", + "Inputs": [ { - "Col": 2, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 2 - } - ], - "Keys": [ - 0 - ], - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select a, b, count(*) as k from user group by a order by 1 asc", - "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(2)", + "Distinct": "false", + "GroupBy": "0", + "Inputs": [ { - "Col": 0, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select a, b, count(*) as k from user group by a order by 1 asc", + "Table": "user" } - ], - "Table": "user" + ] } - } + ] } } @@ -237,55 +188,33 @@ { "Original": "select textcol1, count(*) k from user group by textcol1 order by textcol1, k, textcol1", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ - { - "Col": 2, - "Desc": false - }, + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "2 ASC, 1 ASC, 2 ASC", + "Inputs": [ { - "Col": 1, - "Desc": false - }, - { - "Col": 2, - "Desc": false - } - ], - "Input": { - "Aggregates": [ - { - "Opcode": "count", - "Col": 1 - } - ], - "Keys": [ - 2 - ], - "TruncateColumnCount": 3, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select textcol1, count(*) as k, weight_string(textcol1) from user group by textcol1 order by textcol1 asc, textcol1 asc", - "FieldQuery": "select textcol1, count(*) as k, weight_string(textcol1) from user where 1 != 1 group by textcol1", - "OrderBy": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(1)", + "Distinct": "false", + "GroupBy": "2", + "Inputs": [ { - "Col": 2, - "Desc": false - }, - { - "Col": 2, - "Desc": false + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select textcol1, count(*) as k, weight_string(textcol1) from user group by textcol1 order by textcol1 asc, textcol1 asc", + "Table": "user" } - ], - "TruncateColumnCount": 3, - "Table": "user" + ] } - } + ] } } @@ -294,46 +223,51 @@ { "Original": "select id from (select user.id, user.col from user join user_extra) as t order by id", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "0 ASC", + "Inputs": [ { - "Col": 0, - "Desc": false - } - ], - "Input": { - "Cols": [ - 0 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id, user.col from user", - "FieldQuery": "select user.id, user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - -2 + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "0", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id, user.col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } + ] + } ] } - } + ] } } @@ -342,53 +276,43 @@ { "Original": "select user.col1 as a, user.col2 b, music.col3 c from user, music where user.id = music.id and user.id = 1 order by c", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "2 ASC", + "Inputs": [ { - "Col": 2, - "Desc": false - } - ], - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2 as b, user.id from user where user.id = 1", - "FieldQuery": "select user.col1 as a, user.col2 as b, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select music.col3 as c from music where music.id = :user_id", - "FieldQuery": "select music.col3 as c from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2 as b, user.id from user where user.id = 1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 as c from music where music.id = :user_id", + "Table": "music" + } + ] } - } + ] } } @@ -397,61 +321,43 @@ { "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by 1 asc, 3 desc, 2 asc", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 2, - "Desc": true - }, + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "0 ASC, 2 DESC, 1 ASC", + "Inputs": [ { - "Col": 1, - "Desc": false - } - ], - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1", - "FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select music.col3 from music where music.id = :user_id", - "FieldQuery": "select music.col3 from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 from music where music.id = :user_id", + "Table": "music" + } + ] } - } + ] } } @@ -460,47 +366,42 @@ { "Original": "select u.a, u.textcol1, un.col2 from user u join unsharded un order by u.textcol1, un.col2", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "3 ASC, 2 ASC", + "Inputs": [ { - "Col": 3, - "Desc": false - }, - { - "Col": 2, - "Desc": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1,-3", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select un.col2 from unsharded as un", + "Table": "unsharded" + } + ] } - ], - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", - "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select un.col2 from unsharded as un", - "FieldQuery": "select un.col2 from unsharded as un where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - -2, - 1, - -3 - ] - } + ] } } @@ -509,47 +410,42 @@ { "Original": "select u.a, u.textcol1, un.col2 from unsharded un join user u order by u.textcol1, un.col2", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "3 ASC, 2 ASC", + "Inputs": [ { - "Col": 3, - "Desc": false - }, - { - "Col": 2, - "Desc": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1,2,-1,3", + "TableName": "unsharded_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select un.col2 from unsharded as un", + "Table": "unsharded" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", + "Table": "user" + } + ] } - ], - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select un.col2 from unsharded as un", - "FieldQuery": "select un.col2 from unsharded as un where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", - "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", - "Table": "user" - }, - "Cols": [ - 1, - 2, - -1, - 3 - ] - } + ] } } @@ -558,42 +454,15 @@ { "Original": "select id, keyspace_id, range_start, range_end from user_index where id = :id order by range_start", "Instructions": { - "Opcode": "MemorySort", - "MaxRows": null, - "OrderBy": [ + "OperatorType": "Sort", + "Variant": "Memory", + "TargetDestination": "VtGate()", + "OrderBy": "2 ASC", + "Inputs": [ { - "Col": 2, - "Desc": false + "OperatorType": "vindexfunc - not implemented", + "Variant": "" } - ], - "Input": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "range_start", - "type": 10262 - }, - { - "name": "range_end", - "type": 10262 - } - ], - "Cols": [ - 0, - 1, - 2, - 3 - ], - "Vindex": "user_index", - "Value": ":id" - } + ] } } diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt index d1ab091100e..fffe18492d9 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt @@ -3,13 +3,14 @@ { "Original": "select user.col1 from user having col2 = 2", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.col1 from user having col2 = 2", - "FieldQuery": "select user.col1 from user where 1 != 1", "Table": "user" } } @@ -23,30 +24,34 @@ { "Original": "select user.col1, user_extra.col1 from user join user_extra having user_extra.col1 = 2", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 from user", - "FieldQuery": "select user.col1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 from user", + "Table": "user" }, - "Query": "select user_extra.col1 from user_extra having user_extra.col1 = 2", - "FieldQuery": "select user_extra.col1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.col1 from user_extra having user_extra.col1 = 2", + "Table": "user_extra" + } ] } } @@ -56,31 +61,34 @@ { "Original": "select user.col1 as a, user.col2, user_extra.col3 from user join user_extra having 1 = 1 and a = 1 and a = user.col2 and user_extra.col3 = 1", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2 from user having 1 = 1 and a = 1 and a = user.col2", - "FieldQuery": "select user.col1 as a, user.col2 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2 from user having 1 = 1 and a = 1 and a = user.col2", + "Table": "user" }, - "Query": "select user_extra.col3 from user_extra having user_extra.col3 = 1", - "FieldQuery": "select user_extra.col3 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - -2, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.col3 from user_extra having user_extra.col3 = 1", + "Table": "user_extra" + } ] } } @@ -90,33 +98,33 @@ { "Original": "select id from user having id in (select col from user)", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectIN", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select id from user having :__sq_has_values1 = 1 and id in ::__vals", - "FieldQuery": "select id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - "::__sq1" - ], - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectIN", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user having :__sq_has_values1 = 1 and id in ::__vals", + "Table": "user" + } + ] } } @@ -125,17 +133,14 @@ { "Original": "select col from user where id = 5 order by aa", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user where id = 5 order by aa asc", - "FieldQuery": "select col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -145,17 +150,14 @@ { "Original": "select col from user where id = 1 order by 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user where id = 1 order by 1 asc", - "FieldQuery": "select col from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -165,19 +167,14 @@ { "Original": "select col from user order by col", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user order by col asc", - "FieldQuery": "select col from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], "Table": "user" } } @@ -187,19 +184,14 @@ { "Original": "select * from authoritative order by user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_id, col1, col2 from authoritative order by user_id asc", - "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], "Table": "authoritative" } } @@ -209,20 +201,14 @@ { "Original": "select * from authoritative order by col1", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_id, col1, col2, weight_string(col1) from authoritative order by col1 asc", - "FieldQuery": "select user_id, col1, col2, weight_string(col1) from authoritative where 1 != 1", - "OrderBy": [ - { - "Col": 3, - "Desc": false - } - ], - "TruncateColumnCount": 3, "Table": "authoritative" } } @@ -232,28 +218,14 @@ { "Original": "select a, textcol1, b from user order by a, textcol1, b", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a, textcol1, b, weight_string(textcol1) from user order by a asc, textcol1 asc, b asc", - "FieldQuery": "select a, textcol1, b, weight_string(textcol1) from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 3, - "Desc": false - }, - { - "Col": 2, - "Desc": false - } - ], - "TruncateColumnCount": 3, "Table": "user" } } @@ -263,28 +235,14 @@ { "Original": "select a, user.textcol1, b from user order by a, textcol1, b", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a, user.textcol1, b, weight_string(user.textcol1) from user order by a asc, textcol1 asc, b asc", - "FieldQuery": "select a, user.textcol1, b, weight_string(user.textcol1) from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 3, - "Desc": false - }, - { - "Col": 2, - "Desc": false - } - ], - "TruncateColumnCount": 3, "Table": "user" } } @@ -294,32 +252,14 @@ { "Original": "select a, textcol1, b, textcol2 from user order by a, textcol1, b, textcol2", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user order by a asc, textcol1 asc, b asc, textcol2 asc", - "FieldQuery": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - }, - { - "Col": 4, - "Desc": false - }, - { - "Col": 2, - "Desc": false - }, - { - "Col": 5, - "Desc": false - } - ], - "TruncateColumnCount": 4, "Table": "user" } } @@ -333,13 +273,14 @@ { "Original": "select col from user order by null", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user order by null", - "FieldQuery": "select col from user where 1 != 1", "Table": "user" } } @@ -349,35 +290,33 @@ { "Original": "select col from user where col in (select col2 from user) order by col", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col2 from user", - "FieldQuery": "select col2 from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col2 from user", + "Table": "user" }, - "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by col asc", - "FieldQuery": "select col from user where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by col asc", + "Table": "user" + } + ] } } @@ -386,43 +325,35 @@ { "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by null", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by null", - "FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by null", + "Table": "user" }, - "Query": "select music.col3 from music where music.id = :user_id order by null", - "FieldQuery": "select music.col3 from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 from music where music.id = :user_id order by null", + "Table": "music" + } + ] } } @@ -431,43 +362,35 @@ { "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc", - "FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc", + "Table": "user" }, - "Query": "select music.col3 from music where music.id = :user_id", - "FieldQuery": "select music.col3 from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 from music where music.id = :user_id", + "Table": "music" + } + ] } } @@ -476,43 +399,35 @@ { "Original": "select user.col1 as a, user.col2, music.col3 from user, music where user.id = music.id and user.id = 1 order by a", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc", - "FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by a asc", + "Table": "user" }, - "Query": "select music.col3 from music where music.id = :user_id", - "FieldQuery": "select music.col3 from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 from music where music.id = :user_id", + "Table": "music" + } + ] } } @@ -521,29 +436,33 @@ { "Original": "select col from user where col in (select col2 from user) order by null", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col2 from user", - "FieldQuery": "select col2 from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col2 from user", + "Table": "user" }, - "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by null", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by null", + "Table": "user" + } + ] } } @@ -552,13 +471,14 @@ { "Original": "select col from user order by RAND()", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user order by RAND()", - "FieldQuery": "select col from user where 1 != 1", "Table": "user" } } @@ -568,43 +488,35 @@ { "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by RAND()", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by RAND()", - "FieldQuery": "select user.col1 as a, user.col2, user.id from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], - "Table": "user" - }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "user_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col1 as a, user.col2, user.id from user where user.id = 1 order by RAND()", + "Table": "user" }, - "Query": "select music.col3 from music where music.id = :user_id order by RAND()", - "FieldQuery": "select music.col3 from music where 1 != 1", - "Vindex": "music_user_map", - "Values": [ - ":user_id" - ], - "Table": "music" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_id": 2 - } + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select music.col3 from music where music.id = :user_id order by RAND()", + "Table": "music" + } + ] } } @@ -613,29 +525,33 @@ { "Original": "select col from user where col in (select col2 from user) order by rand()", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col2 from user", - "FieldQuery": "select col2 from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col2 from user", + "Table": "user" }, - "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by rand()", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by rand()", + "Table": "user" + } + ] } } @@ -644,17 +560,14 @@ { "Original": "select * from user where id = 5 order by col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by col asc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -664,17 +577,14 @@ { "Original": "select user.* from user where id = 5 order by user.col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.* from user where id = 5 order by user.col asc", - "FieldQuery": "select user.* from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -684,17 +594,14 @@ { "Original": "select * from user where id = 5 order by user.col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by user.col asc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -704,34 +611,35 @@ { "Original": "select u.id, e.id from user u join user_extra e where u.col = e.col and u.col in (select * from user where user.id = u.id order by col)", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.id, u.col from user as u where u.col in (select * from user where user.id = u.id order by col asc)", - "FieldQuery": "select u.id, u.col from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id, u.col from user as u where u.col in (select * from user where user.id = u.id order by col asc)", + "Table": "user" }, - "Query": "select e.id from user_extra as e where e.col = :u_col", - "FieldQuery": "select e.id from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "u_col": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.id from user_extra as e where e.col = :u_col", + "Table": "user_extra" + } + ] } } @@ -756,17 +664,14 @@ { "Original": "select * from user where id = 5 order by user.col collate utf8_general_ci", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by user.col collate utf8_general_ci asc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -776,17 +681,14 @@ { "Original": "select * from user where id = 5 order by -col1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by -col1 asc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -796,17 +698,14 @@ { "Original": "select * from user where id = 5 order by concat(col,col1) collate utf8_general_ci desc", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by concat(col, col1) collate utf8_general_ci desc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -816,17 +715,14 @@ { "Original": "select * from user where id = 5 order by id+col collate utf8_general_ci desc", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 order by id + col collate utf8_general_ci desc", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -836,17 +732,14 @@ { "Original": "select * from user u join (select user_id from user_extra where user_id = 5) eu on u.id = eu.user_id where u.id = 5 order by eu.user_id", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "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", - "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", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -856,17 +749,14 @@ { "Original": "select col from route1 where id = 1 order by col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user as route1 where id = 1 order by col asc", - "FieldQuery": "select col from user as route1 where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -876,17 +766,14 @@ { "Original": "select col from route1 where email = 'aaa' order by col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user_metadata as route1 where email = 'aaa' order by col asc", - "FieldQuery": "select col from user_metadata as route1 where 1 != 1", - "Vindex": "email_user_map", - "Values": [ - "aaa" - ], "Table": "user_metadata" } } @@ -896,17 +783,14 @@ { "Original": "select col1 from user where id = 1 limit 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col1 from user where id = 1 limit 1", - "FieldQuery": "select col1 from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -917,35 +801,43 @@ { "Original": "select user.col from user join user_extra limit 1", "Instructions": { - "Opcode": "Limit", - "Count": 1, - "Offset": null, - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 - ] - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(1)", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra", + "Table": "user_extra" + } + ] + } + ] } } @@ -954,19 +846,23 @@ { "Original": "select col from user limit 1", "Instructions": { - "Opcode": "Limit", - "Count": 1, - "Offset": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user limit :__upper_limit", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(1)", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user limit :__upper_limit", + "Table": "user" + } + ] } } @@ -975,19 +871,23 @@ { "Original": "select col from user limit :a", "Instructions": { - "Opcode": "Limit", - "Count": ":a", - "Offset": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user limit :__upper_limit", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "NULL", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user limit :__upper_limit", + "Table": "user" + } + ] } } @@ -996,19 +896,23 @@ { "Original": "select * from user where (id1 = 4 AND name1 ='abc') limit 5", "Instructions": { - "Opcode": "Limit", - "Count": 5, - "Offset": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select * from user where id1 = 4 and name1 = 'abc' limit :__upper_limit", - "FieldQuery": "select * from user where 1 != 1", - "Table": "user" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(5)", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select * from user where id1 = 4 and name1 = 'abc' limit :__upper_limit", + "Table": "user" + } + ] } } @@ -1017,34 +921,41 @@ { "Original": "select col from user where col in (select col1 from user) limit 1", "Instructions": { - "Opcode": "Limit", - "Count": 1, - "Offset": null, - "Input": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col1 from user", - "FieldQuery": "select col1 from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 limit :__upper_limit", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(1)", + "Inputs": [ + { + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col1 from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 limit :__upper_limit", + "Table": "user" + } + ] } - } + ] } } @@ -1053,13 +964,13 @@ { "Original": "select col from ref limit 1", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select col from ref limit 1", - "FieldQuery": "select col from ref where 1 != 1", "Table": "ref" } } diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index 682b235e150..9868ddf8c57 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -3,13 +3,14 @@ { "Original": "select 1 from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select 1 from user", - "FieldQuery": "select 1 from user where 1 != 1", "Table": "user" } } @@ -19,13 +20,14 @@ { "Original": "select user.* from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.* from user", - "FieldQuery": "select user.* from user where 1 != 1", "Table": "user" } } @@ -35,13 +37,14 @@ { "Original": "select * from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user", - "FieldQuery": "select * from user where 1 != 1", "Table": "user" } } @@ -51,14 +54,14 @@ { "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", - "FieldQuery": "select * from user where 1 != 1", - "QueryTimeout": 1000, "Table": "user" } } @@ -68,24 +71,25 @@ { "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", - "FieldQuery": "select count(*) from user where 1 != 1", - "QueryTimeout": 1000, - "Table": "user" - } + ] } } @@ -94,20 +98,23 @@ { "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit :__upper_limit", - "FieldQuery": "select * from user where 1 != 1", - "QueryTimeout": 1000, - "Table": "user" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit :__upper_limit", + "Table": "user" + } + ] } } @@ -116,14 +123,14 @@ { "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user", - "FieldQuery": "select * from user where 1 != 1", - "ScatterErrorsAsWarnings": true, "Table": "user" } } @@ -133,24 +140,25 @@ { "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", - "FieldQuery": "select count(*) from user where 1 != 1", - "ScatterErrorsAsWarnings": true, - "Table": "user" - } + ] } } @@ -159,24 +167,25 @@ { "Original": "/*VT_SPAN_CONTEXT=123*/select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Instructions": { - "Aggregates": [ + "OperatorType": "Aggregate", + "Variant": "Ordered", + "TargetDestination": "VtGate()", + "Aggregates": "count(0)", + "Distinct": "false", + "GroupBy": "", + "Inputs": [ { - "Opcode": "count", - "Col": 0 + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", + "Table": "user" } - ], - "Keys": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", - "FieldQuery": "select count(*) from user where 1 != 1", - "ScatterErrorsAsWarnings": true, - "Table": "user" - } + ] } } @@ -185,20 +194,23 @@ { "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit :__upper_limit", - "FieldQuery": "select * from user where 1 != 1", - "ScatterErrorsAsWarnings": true, - "Table": "user" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit :__upper_limit", + "Table": "user" + } + ] } } @@ -207,13 +219,14 @@ { "Original": "select user.* from user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.* from user", - "FieldQuery": "select user.* from user where 1 != 1", "Table": "user" } } @@ -223,13 +236,14 @@ { "Original": "select user.user.* from user.user", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.* from user", - "FieldQuery": "select user.* from user where 1 != 1", "Table": "user" } } @@ -239,13 +253,14 @@ { "Original": "select * from authoritative", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user_id, col1, col2 from authoritative", - "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", "Table": "authoritative" } } @@ -255,13 +270,14 @@ { "Original": "select * from authoritative a join authoritative b on a.user_id=b.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id", - "FieldQuery": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id where 1 != 1", "Table": "authoritative" } } @@ -275,13 +291,14 @@ { "Original": "select a.* from authoritative a", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a.user_id, a.col1, a.col2 from authoritative as a", - "FieldQuery": "select a.user_id, a.col1, a.col2 from authoritative as a where 1 != 1", "Table": "authoritative" } } @@ -291,13 +308,14 @@ { "Original": "select * from authoritative join user on authoritative.user_id=user.id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from authoritative join user on authoritative.user_id = user.id", - "FieldQuery": "select * from authoritative join user on authoritative.user_id = user.id where 1 != 1", "Table": "authoritative" } } @@ -307,13 +325,14 @@ { "Original": "select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id", - "FieldQuery": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id where 1 != 1", "Table": "authoritative" } } @@ -323,13 +342,14 @@ { "Original": "select col from user join user_extra on user.id = user_extra.user_id", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from user join user_extra on user.id = user_extra.user_id", - "FieldQuery": "select col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Table": "user" } } @@ -343,30 +363,34 @@ { "Original": "select id, user_id from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select id from user", - "FieldQuery": "select id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select id from user", + "Table": "user" }, - "Query": "select user_id from user_extra", - "FieldQuery": "select user_id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_id from user_extra", + "Table": "user_extra" + } ] } } @@ -376,13 +400,13 @@ { "Original": "select database() from dual", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select :__vtdbname as `database()` from dual", - "FieldQuery": "select :__vtdbname as `database()` from dual where 1 != 1", "Table": "dual" } } @@ -396,13 +420,13 @@ { "Original": "select last_insert_id() as x from main.unsharded", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select :__lastInsertId as x from unsharded", - "FieldQuery": "select :__lastInsertId as x from unsharded where 1 != 1", "Table": "unsharded" } } @@ -412,13 +436,13 @@ { "Original": "select @@session.auto_increment_increment from dual", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select @@session.auto_increment_increment from dual", - "FieldQuery": "select @@session.auto_increment_increment from dual where 1 != 1", "Table": "dual" } } @@ -428,17 +452,13 @@ { "Original": "select * from pin_test", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select * from pin_test", - "FieldQuery": "select * from pin_test where 1 != 1", - "Vindex": "binary", - "Values": [ - "\ufffd" - ], "Table": "pin_test" } } @@ -448,13 +468,13 @@ { "Original": "select @@session.auto_increment_increment from user.dual", "Instructions": { - "Opcode": "SelectReference", + "OperatorType": "Route", + "Variant": "SelectReference", "Keyspace": { "Name": "user", "Sharded": true }, "Query": "select @@session.auto_increment_increment from dual", - "FieldQuery": "select @@session.auto_increment_increment from dual where 1 != 1", "Table": "dual" } } @@ -464,29 +484,34 @@ { "Original": "select user_extra.id from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user", - "FieldQuery": "select 1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user", + "Table": "user" }, - "Query": "select user_extra.id from user_extra", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra", + "Table": "user_extra" + } ] } } @@ -496,30 +521,34 @@ { "Original": "select user.col, user_extra.id from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" }, - "Query": "select user_extra.id from user_extra", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra", + "Table": "user_extra" + } ] } } @@ -529,30 +558,34 @@ { "Original": "select user.col, user_extra.id + user_extra.col from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user", + "Table": "user" }, - "Query": "select user_extra.id + user_extra.col from user_extra", - "FieldQuery": "select user_extra.id + user_extra.col from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id + user_extra.col from user_extra", + "Table": "user_extra" + } ] } } @@ -562,31 +595,34 @@ { "Original": "select user.col, user_extra.id, user.col2 from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col, user.col2 from user", - "FieldQuery": "select user.col, user.col2 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col, user.col2 from user", + "Table": "user" }, - "Query": "select user_extra.id from user_extra", - "FieldQuery": "select user_extra.id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1, - -2 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id from user_extra", + "Table": "user_extra" + } ] } } @@ -596,29 +632,34 @@ { "Original": "select /* comment */ user.col from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select /* comment */ user.col from user", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /* comment */ user.col from user", + "Table": "user" }, - "Query": "select /* comment */ 1 from user_extra", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select /* comment */ 1 from user_extra", + "Table": "user_extra" + } ] } } @@ -628,29 +669,34 @@ { "Original": "select user.col from user join user_extra for update", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.col from user for update", - "FieldQuery": "select user.col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.col from user for update", + "Table": "user" }, - "Query": "select 1 from user_extra for update", - "FieldQuery": "select 1 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user_extra for update", + "Table": "user_extra" + } ] } } @@ -660,34 +706,34 @@ { "Original": "select user.id, (select user.id+outm.m+unsharded.m from unsharded) from user join unsharded outm", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id from user", - "FieldQuery": "select user.id from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id from user", + "Table": "user" }, - "Query": "select (select :user_id + outm.m + unsharded.m from unsharded) from unsharded as outm", - "FieldQuery": "select (select :user_id + outm.m + unsharded.m from unsharded where 1 != 1) from unsharded as outm where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "user_id": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select (select :user_id + outm.m + unsharded.m from unsharded) from unsharded as outm", + "Table": "unsharded" + } + ] } } @@ -696,30 +742,34 @@ { "Original": "select user.Col, user_extra.Id from user join user_extra", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.Col from user", - "FieldQuery": "select user.Col from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.Col from user", + "Table": "user" }, - "Query": "select user_extra.Id from user_extra", - "FieldQuery": "select user_extra.Id from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.Id from user_extra", + "Table": "user_extra" + } ] } } @@ -733,13 +783,14 @@ { "Original": "select * from user where id = 0x04", "Instructions": { - "Opcode": "SelectScatter", + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 0x04", - "FieldQuery": "select * from user where 1 != 1", "Table": "user" } } @@ -749,25 +800,24 @@ { "Original": "select user_id from music order by user_id limit 10, 20", "Instructions": { - "Opcode": "Limit", - "Count": 20, - "Offset": 10, - "Input": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user_id from music order by user_id asc limit :__upper_limit", - "FieldQuery": "select user_id from music where 1 != 1", - "OrderBy": [ - { - "Col": 0, - "Desc": false - } - ], - "Table": "music" - } + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(20)", + "Offset": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_id from music order by user_id asc limit :__upper_limit", + "Table": "music" + } + ] } } @@ -776,17 +826,14 @@ { "Original": "select * from user where name ='abc' AND (id = 4) limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where name = 'abc' and id = 4 limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 4 - ], "Table": "user" } } @@ -796,17 +843,14 @@ { "Original": "select * from user where (id = 4) AND (name ='abc') limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 4 and name = 'abc' limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 4 - ], "Table": "user" } } @@ -816,17 +860,14 @@ { "Original": "select * from user where (id = 4 and name ='abc') limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 4 and name = 'abc' limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 4 - ], "Table": "user" } } @@ -836,18 +877,14 @@ { "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col desc limit 2", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select user0_.col as col0_ from user as user0_ where id = 1 - user0_.col desc limit 2", - "FieldQuery": "select user0_.col as col0_ from user as user0_ where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], + "TargetTabletType": "MASTER", + "Query": "select user0_.col as col0_ from user as user0_ where id = 1 order by user0_.col desc limit 2", "Table": "user" } } @@ -857,17 +894,14 @@ { "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc limit 3", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select user0_.col as col0_ from user as user0_ where id = 1 order by col0_ desc limit 3", - "FieldQuery": "select user0_.col as col0_ from user as user0_ where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -877,17 +911,14 @@ { "Original": "select * from user where (id = 1) AND name = true limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 1 and name = true limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -897,17 +928,14 @@ { "Original": "select * from user where (id = 1) AND name limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 1 and name limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "user" } } @@ -917,17 +945,14 @@ { "Original": "select * from user where (id = 5) AND name = true limit 5", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from user where id = 5 and name = true limit 5", - "FieldQuery": "select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 5 - ], "Table": "user" } } @@ -937,29 +962,32 @@ { "Original": "select a, (select col from user) from unsharded", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select a, :__sq1 from unsharded", - "FieldQuery": "select a, :__sq1 from unsharded where 1 != 1", - "Table": "unsharded" - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select a, :__sq1 from unsharded", + "Table": "unsharded" + } + ] } } @@ -968,29 +996,32 @@ { "Original": "select a, 1+(select col from user) from unsharded", "Instructions": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select a, 1 + :__sq1 from unsharded", - "FieldQuery": "select a, 1 + :__sq1 from unsharded where 1 != 1", - "Table": "unsharded" - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select a, 1 + :__sq1 from unsharded", + "Table": "unsharded" + } + ] } } @@ -999,37 +1030,43 @@ { "Original": "select * from (select user.id id1, user_extra.id id2 from user join user_extra) as t", "Instructions": { - "Cols": [ - 0, - 1 - ], - "Subquery": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user.id as id1 from user", - "FieldQuery": "select user.id as id1 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select user_extra.id as id2 from user_extra", - "FieldQuery": "select user_extra.id as id2 from user_extra where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 - ] - } + "OperatorType": "Subquery", + "Variant": "", + "TargetDestination": "VtGate()", + "Columns": "0, 1", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user.id as id1 from user", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select user_extra.id as id2 from user_extra", + "Table": "user_extra" + } + ] + } + ] } } @@ -1046,13 +1083,14 @@ { "Original": "select * from information_schema.a union select * from information_schema.b", "Instructions": { - "Opcode": "SelectDBA", + "OperatorType": "Route", + "Variant": "SelectDBA", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from information_schema.a union select * from information_schema.b", - "FieldQuery": "select * from information_schema.a where 1 != 1 union select * from information_schema.b where 1 != 1" + "Table": "" } } @@ -1061,17 +1099,14 @@ { "Original": "select * from music where user_id = 1 union select * from user where id = 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select * from music where user_id = 1 union select * from user where id = 1", - "FieldQuery": "select * from music where 1 != 1 union select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "music" } } @@ -1081,17 +1116,14 @@ { "Original": "select *, last_insert_id() from music where user_id = 1 union select * from user where id = 1", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select *, :__lastInsertId as `last_insert_id()` from music where user_id = 1 union select * from user where id = 1", - "FieldQuery": "select *, :__lastInsertId as `last_insert_id()` from music where 1 != 1 union select * from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - 1 - ], "Table": "music" } } @@ -1100,13 +1132,13 @@ { "Original": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) as a", - "FieldQuery": "select * from (select col1, col2 from unsharded where 1 != 1 union select col1, col2 from unsharded where 1 != 1) as a where 1 != 1", "Table": "unsharded" } } @@ -1115,13 +1147,13 @@ { "Original": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", - "FieldQuery": "select id, name from unsharded where 1 != 1", "Table": "unsharded" } } @@ -1130,13 +1162,13 @@ { "Original": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "(select id from unsharded) union (select id from unsharded_auto) order by id asc limit 5", - "FieldQuery": "(select id from unsharded where 1 != 1) union (select id from unsharded_auto where 1 != 1)", "Table": "unsharded" } } @@ -1145,13 +1177,13 @@ { "Original": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", - "FieldQuery": "select id from unsharded where 1 != 1 union select id from unsharded_auto where 1 != 1 union select id from unsharded_auto where 1 != 1", "Table": "unsharded" } } @@ -1160,13 +1192,13 @@ { "Original": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", - "FieldQuery": "(select id from unsharded where 1 != 1 union select id from unsharded_auto where 1 != 1) union (select id from unsharded_auto where 1 != 1 union select name from unsharded where 1 != 1)", "Table": "unsharded" } } @@ -1175,13 +1207,13 @@ { "Original": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", - "FieldQuery": "(select id from unsharded where 1 != 1) union (select id from unsharded where 1 != 1)", "Table": "unsharded" } } @@ -1191,17 +1223,14 @@ { "Original": "select a from route1 where email = 'aaa' union select b from route1 where email = 'aaa'", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select a from user_metadata as route1 where email = 'aaa' union select b from user_metadata as route1 where email = 'aaa'", - "FieldQuery": "select a from user_metadata as route1 where 1 != 1 union select b from user_metadata as route1 where 1 != 1", - "Vindex": "email_user_map", - "Values": [ - "aaa" - ], "Table": "user_metadata" } } @@ -1211,14 +1240,13 @@ { "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from route2", "Instructions": { - "Opcode": "SelectUnsharded", + "OperatorType": "Route", + "Variant": "SelectUnsharded", "Keyspace": { "Name": "main", "Sharded": false }, "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from unsharded as route2", - "FieldQuery": "select * from unsharded as route2 where 1 != 1", - "QueryTimeout": 1000, "Table": "unsharded" } } diff --git a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt index e094a6054ab..70bd38db048 100644 --- a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt @@ -5,34 +5,34 @@ { "Original": "select predef2, predef3 from user join unsharded on predef2 = predef3", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select predef2 from user", + "Table": "user" }, - "Query": "select predef2 from user", - "FieldQuery": "select predef2 from user where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "Query": "select predef3 from unsharded where predef3 = :predef2", - "FieldQuery": "select predef3 from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "predef2": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select predef3 from unsharded where predef3 = :predef2", + "Table": "unsharded" + } + ] } } diff --git a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt index 6b3b182d2b7..8afb86c3acc 100644 --- a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt @@ -3,33 +3,8 @@ { "Original": "select id, keyspace_id, range_start, range_end from user_index where id = :id", "Instructions": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "range_start", - "type": 10262 - }, - { - "name": "range_end", - "type": 10262 - } - ], - "Cols": [ - 0, - 1, - 2, - 3 - ], - "Vindex": "user_index", - "Value": ":id" + "OperatorType": "vindexfunc - not implemented", + "Variant": "" } } @@ -38,33 +13,8 @@ { "Original": "select * from user_index where id = :id", "Instructions": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "range_start", - "type": 10262 - }, - { - "name": "range_end", - "type": 10262 - } - ], - "Cols": [ - 0, - 1, - 2, - 3 - ], - "Vindex": "user_index", - "Value": ":id" + "OperatorType": "vindexfunc - not implemented", + "Variant": "" } } @@ -73,28 +23,8 @@ { "Original": "select id, keyspace_id, id from user_index where id = :id", "Instructions": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "id", - "type": 10262 - } - ], - "Cols": [ - 0, - 1, - 0 - ], - "Vindex": "user_index", - "Value": ":id" + "OperatorType": "vindexfunc - not implemented", + "Variant": "" } } @@ -107,28 +37,8 @@ { "Original": "select id, keyspace_id, id from second_user.hash_dup where id = :id", "Instructions": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "id", - "type": 10262 - } - ], - "Cols": [ - 0, - 1, - 0 - ], - "Vindex": "hash_dup", - "Value": ":id" + "OperatorType": "vindexfunc - not implemented", + "Variant": "" } } @@ -137,34 +47,26 @@ { "Original": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "keyspace_id", - "type": 10262 - } - ], - "Cols": [ - 1 - ], - "Vindex": "user_index", - "Value": ":id" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "_unsharded", + "Inputs": [ + { + "OperatorType": "vindexfunc - not implemented", + "Variant": "" }, - "Query": "select unsharded.id from unsharded", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded", + "Table": "unsharded" + } ] } } @@ -174,34 +76,26 @@ { "Original": "select user_index.keyspace_id, unsharded.id from unsharded join user_index where user_index.id = :id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1,-1", + "TableName": "unsharded_", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded", + "Table": "unsharded" }, - "Query": "select unsharded.id from unsharded", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Right": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "keyspace_id", - "type": 10262 - } - ], - "Cols": [ - 1 - ], - "Vindex": "user_index", - "Value": ":id" - }, - "Cols": [ - 1, - -1 + { + "OperatorType": "vindexfunc - not implemented", + "Variant": "" + } ] } } @@ -211,44 +105,27 @@ { "Original": "select user_index.id, user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "id", - "type": 10262 - }, - { - "name": "keyspace_id", - "type": 10262 - } - ], - "Cols": [ - 0, - 1 - ], - "Vindex": "user_index", - "Value": ":id" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2,1", + "TableName": "_unsharded", + "Inputs": [ + { + "OperatorType": "vindexfunc - not implemented", + "Variant": "" }, - "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - -2, - 1 - ], - "Vars": { - "user_index_id": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", + "Table": "unsharded" + } + ] } } @@ -257,43 +134,27 @@ { "Original": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "id", - "type": 10262 - } - ], - "Cols": [ - 1, - 0 - ], - "Vindex": "user_index", - "Value": ":id" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "_unsharded", + "Inputs": [ + { + "OperatorType": "vindexfunc - not implemented", + "Variant": "" }, - "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "user_index_id": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", + "Table": "unsharded" + } + ] } } @@ -302,43 +163,27 @@ { "Original": "select ui.keyspace_id, unsharded.id from user_index ui join unsharded where ui.id = :id and unsharded.id = ui.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "VindexMap", - "Fields": [ - { - "name": "keyspace_id", - "type": 10262 - }, - { - "name": "id", - "type": 10262 - } - ], - "Cols": [ - 1, - 0 - ], - "Vindex": "user_index", - "Value": ":id" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "_unsharded", + "Inputs": [ + { + "OperatorType": "vindexfunc - not implemented", + "Variant": "" }, - "Query": "select unsharded.id from unsharded where unsharded.id = :ui_id", - "FieldQuery": "select unsharded.id from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "ui_id": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.id from unsharded where unsharded.id = :ui_id", + "Table": "unsharded" + } + ] } } @@ -349,17 +194,14 @@ { "Original": "select * from samecolvin where col = :col", "Instructions": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Route", + "Variant": "SelectEqualUnique", "Keyspace": { "Name": "user", "Sharded": true }, + "TargetTabletType": "MASTER", "Query": "select col from samecolvin where col = :col", - "FieldQuery": "select col from samecolvin where 1 != 1", - "Vindex": "vindex1", - "Values": [ - ":col" - ], "Table": "samecolvin" } } diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt index 2ce3e559caa..c1074daf549 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt @@ -3,35 +3,35 @@ { "Original": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.id as uid from user as u", - "FieldQuery": "select u.id as uid from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1,-1,2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id as uid from user as u", + "Table": "user" }, - "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid", - "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - 1, - -1, - 2 - ], - "Vars": { - "uid": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid", + "Table": "user_extra" + } + ] } } @@ -40,35 +40,35 @@ { "Original": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid and e.col = :uid", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.id as uid from user as u", - "FieldQuery": "select u.id as uid from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1,-1,2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id as uid from user as u", + "Table": "user" }, - "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid1 and e.col = :uid", - "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - 1, - -1, - 2 - ], - "Vars": { - "uid1": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid1 and e.col = :uid", + "Table": "user_extra" + } + ] } } @@ -77,50 +77,55 @@ { "Original": "select u1.id from user u1 join user u2 join user u3 where u3.col = u1.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u1.id, u1.col from user as u1", - "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", - "Table": "user" + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_user", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u1.id, u1.col from user as u1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u2", + "Table": "user" + } + ] }, - "Right": { - "Opcode": "SelectScatter", + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user as u2", - "FieldQuery": "select 1 from user as u2 where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" - }, - "Cols": [ - -1, - -2 - ] - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user as u3 where u3.col = :u1_col", - "FieldQuery": "select 1 from user as u3 where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1 - ], - "Vars": { - "u1_col": 1 - } + } + ] } } @@ -129,50 +134,55 @@ { "Original": "select u1.id from user u1 join user u2 join user u3 where u3.col = u2.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u1.id from user as u1", - "FieldQuery": "select u1.id from user as u1 where 1 != 1", - "Table": "user" + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_user", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u1.id from user as u1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u2.col from user as u2", + "Table": "user" + } + ] }, - "Right": { - "Opcode": "SelectScatter", + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select u2.col from user as u2", - "FieldQuery": "select u2.col from user as u2 where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u3 where u3.col = :u2_col", "Table": "user" - }, - "Cols": [ - -1, - 1 - ] - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user as u3 where u3.col = :u2_col", - "FieldQuery": "select 1 from user as u3 where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1 - ], - "Vars": { - "u2_col": 1 - } + } + ] } } @@ -181,53 +191,55 @@ { "Original": "select u1.id from user u1 join user u2 on u2.col = u1.col join user u3 where u3.col = u1.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u1.id, u1.col from user as u1", - "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", - "Table": "user" + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_user", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u1.id, u1.col from user as u1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u2 where u2.col = :u1_col", + "Table": "user" + } + ] }, - "Right": { - "Opcode": "SelectScatter", + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user as u2 where u2.col = :u1_col", - "FieldQuery": "select 1 from user as u2 where 1 != 1", + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" - }, - "Cols": [ - -1, - -2 - ], - "Vars": { - "u1_col": 1 } - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user as u3 where u3.col = :u1_col", - "FieldQuery": "select 1 from user as u3 where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1 - ], - "Vars": { - "u1_col": 1 - } + ] } } @@ -239,74 +251,75 @@ { "Original": "select u1.id from user u1 join user u2 join user u3 on u3.id = u1.col join user u4 where u4.col = u1.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u1.id, u1.col from user as u1", - "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_user_user", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user_user", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,-2", + "TableName": "user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u1.id, u1.col from user as u1", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u2", + "Table": "user" + } + ] }, - "Query": "select 1 from user as u2", - "FieldQuery": "select 1 from user as u2 where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1, - -2 + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u3 where u3.id = :u1_col", + "Table": "user" + } ] }, - "Right": { - "Opcode": "SelectEqualUnique", + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user as u3 where u3.id = :u1_col", - "FieldQuery": "select 1 from user as u3 where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":u1_col" - ], + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u4 where u4.col = :u1_col", "Table": "user" - }, - "Cols": [ - -1, - -2 - ], - "Vars": { - "u1_col": 1 } - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user as u4 where u4.col = :u1_col", - "FieldQuery": "select 1 from user as u4 where 1 != 1", - "Table": "user" - }, - "Cols": [ - -1 - ], - "Vars": { - "u1_col": 1 - } + ] } } @@ -315,54 +328,55 @@ { "Original": "select u1.id from user u1 join (user u2 join user u3) where u2.id = u1.col and u3.id = u1.col", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u1.id, u1.col from user as u1", - "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectEqualUnique", + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1", + "TableName": "user_user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", "Keyspace": { "Name": "user", "Sharded": true }, - "Query": "select 1 from user as u2 where u2.id = :u1_col", - "FieldQuery": "select 1 from user as u2 where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":u1_col" - ], + "TargetTabletType": "MASTER", + "Query": "select u1.id, u1.col from user as u1", "Table": "user" }, - "Right": { - "Opcode": "SelectEqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user as u3 where u3.id = :u1_col", - "FieldQuery": "select 1 from user as u3 where 1 != 1", - "Vindex": "user_index", - "Values": [ - ":u1_col" - ], - "Table": "user" + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "", + "TableName": "user_user", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u2 where u2.id = :u1_col", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select 1 from user as u3 where u3.id = :u1_col", + "Table": "user" + } + ] } - }, - "Cols": [ - -1 - ], - "Vars": { - "u1_col": 1 - } + ] } } @@ -371,34 +385,34 @@ { "Original": "select `weird``name`.a, unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name`", - "FieldQuery": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name` where 1 != 1", - "Table": "weird`name" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "weird`name_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name`", + "Table": "weird`name" }, - "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", - "FieldQuery": "select unsharded.b from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "weird_name_a_b_c": 1 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", + "Table": "unsharded" + } + ] } } @@ -407,33 +421,34 @@ { "Original": "select unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "Instructions": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select `weird``name`.`a``b*c` from `weird``name`", - "FieldQuery": "select `weird``name`.`a``b*c` from `weird``name` where 1 != 1", - "Table": "weird`name" - }, - "Right": { - "Opcode": "SelectUnsharded", - "Keyspace": { - "Name": "main", - "Sharded": false + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "1", + "TableName": "weird`name_unsharded", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select `weird``name`.`a``b*c` from `weird``name`", + "Table": "weird`name" }, - "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", - "FieldQuery": "select unsharded.b from unsharded where 1 != 1", - "Table": "unsharded" - }, - "Cols": [ - 1 - ], - "Vars": { - "weird_name_a_b_c": 0 - } + { + "OperatorType": "Route", + "Variant": "SelectUnsharded", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", + "Table": "unsharded" + } + ] } } @@ -442,39 +457,43 @@ { "Original": "select u.id, e.id from user u join user_extra e where e.id = u.col limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.id, u.col from user as u", - "FieldQuery": "select u.id, u.col from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select e.id from user_extra as e where e.id = :u_col", - "FieldQuery": "select e.id from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "u_col": 1 + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id, u.col from user as u", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.id from user_extra as e where e.id = :u_col", + "Table": "user_extra" + } + ] } - } + ] } } @@ -483,58 +502,61 @@ { "Original": "select 1 from user where id in (select u.id, e.id from user u join user_extra e where e.id = u.col limit 10)", "Instructions": { - "Opcode": "PulloutIn", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select u.id, u.col from user as u", - "FieldQuery": "select u.id, u.col from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select e.id from user_extra as e where e.id = :u_col", - "FieldQuery": "select e.id from user_extra as e where 1 != 1", - "Table": "user_extra" + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id, u.col from user as u", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.id from user_extra as e where e.id = :u_col", + "Table": "user_extra" + } + ] + } + ] + }, + { + "OperatorType": "Route", + "Variant": "SelectIN", + "Keyspace": { + "Name": "user", + "Sharded": true }, - "Cols": [ - -1, - 1 - ], - "Vars": { - "u_col": 1 - } + "TargetTabletType": "MASTER", + "Query": "select 1 from user where :__sq_has_values1 = 1 and id in ::__vals", + "Table": "user" } - }, - "Underlying": { - "Opcode": "SelectIN", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select 1 from user where :__sq_has_values1 = 1 and id in ::__vals", - "FieldQuery": "select 1 from user where 1 != 1", - "Vindex": "user_index", - "Values": [ - "::__sq1" - ], - "Table": "user" - } + ] } } @@ -543,55 +565,61 @@ { "Original": "select u.id, e.id, (select col from user) from user u join user_extra e where e.id = u.col limit 10", "Instructions": { - "Opcode": "Limit", - "Count": 10, - "Offset": null, - "Input": { - "Opcode": "PulloutValue", - "SubqueryResult": "__sq1", - "HasValues": "__sq_has_values1", - "Subquery": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select col from user", - "FieldQuery": "select col from user where 1 != 1", - "Table": "user" - }, - "Underlying": { - "Opcode": "Join", - "Left": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true + "OperatorType": "Limit", + "Variant": "", + "TargetDestination": "VtGate()", + "Count": "INT64(10)", + "Inputs": [ + { + "OperatorType": "Subquery", + "Variant": "PulloutValue", + "TargetDestination": "VtGate()", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select col from user", + "Table": "user" }, - "Query": "select u.id, :__sq1, u.col from user as u", - "FieldQuery": "select u.id, :__sq1, u.col from user as u where 1 != 1", - "Table": "user" - }, - "Right": { - "Opcode": "SelectScatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "Query": "select e.id from user_extra as e where e.id = :u_col", - "FieldQuery": "select e.id from user_extra as e where 1 != 1", - "Table": "user_extra" - }, - "Cols": [ - -1, - 1, - -2 - ], - "Vars": { - "u_col": 2 - } + { + "OperatorType": "Join", + "Variant": "Join", + "TargetDestination": "VtGate()", + "JoinColumnIndexes": "-1,1,-2", + "TableName": "user_user_extra", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select u.id, :__sq1, u.col from user as u", + "Table": "user" + }, + { + "OperatorType": "Route", + "Variant": "SelectScatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "TargetTabletType": "MASTER", + "Query": "select e.id from user_extra as e where e.id = :u_col", + "Table": "user_extra" + } + ] + } + ] } - } + ] } } From f5d9a386c70241f1d1c8a7ca0875cac976f0c6ae Mon Sep 17 00:00:00 2001 From: Saif Alharthi Date: Thu, 2 Apr 2020 22:42:20 -0700 Subject: [PATCH 08/10] Primitive descriptions clean up Signed-off-by: Saif Alharthi Signed-off-by: Andres Taylor --- go/vt/key/destination.go | 23 -- go/vt/vtgate/engine/delete.go | 49 +-- go/vt/vtgate/engine/insert.go | 42 +-- go/vt/vtgate/engine/join.go | 11 +- go/vt/vtgate/engine/limit.go | 31 +- go/vt/vtgate/engine/memory_sort.go | 28 +- go/vt/vtgate/engine/merge_sort.go | 14 +- go/vt/vtgate/engine/ordered_aggregate.go | 11 +- go/vt/vtgate/engine/plan_description.go | 15 +- go/vt/vtgate/engine/plan_description_test.go | 10 +- go/vt/vtgate/engine/pullout_subquery.go | 7 +- go/vt/vtgate/engine/route.go | 15 +- go/vt/vtgate/engine/send.go | 2 +- go/vt/vtgate/engine/subquery.go | 10 +- go/vt/vtgate/engine/update.go | 12 +- .../planbuilder/testdata/aggr_cases.txt | 120 +++--- .../planbuilder/testdata/bypass_cases.txt | 12 +- .../vtgate/planbuilder/testdata/dml_cases.txt | 353 +++++++++--------- .../planbuilder/testdata/filter_cases.txt | 298 ++++++++++++--- .../planbuilder/testdata/from_cases.txt | 262 +++++++++---- .../testdata/memory_sort_cases.txt | 71 ++-- .../testdata/postprocess_cases.txt | 212 ++++++++--- .../planbuilder/testdata/select_cases.txt | 178 +++++++-- .../planbuilder/testdata/symtab_cases.txt | 3 +- .../testdata/vindex_func_cases.txt | 17 +- .../planbuilder/testdata/wireup_cases.txt | 86 +++-- 26 files changed, 1166 insertions(+), 726 deletions(-) diff --git a/go/vt/key/destination.go b/go/vt/key/destination.go index b554a1e2e3e..66946504978 100644 --- a/go/vt/key/destination.go +++ b/go/vt/key/destination.go @@ -443,29 +443,6 @@ func (d DestinationAllShards) String() string { return "DestinationAllShards()" } -// -// DestinationVtGate -// - -// DestinationVtGate implies primitive executes entirely on vtgate -// It implements the Destination interface. -type DestinationVtGate struct{} - -// IsUnique is part of the Destination interface. -func (d DestinationVtGate) IsUnique() bool { - return true -} - -// Resolve is part of the Destination interface. -func (d DestinationVtGate) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error { - return nil -} - -// String is part of the Destination interface. -func (d DestinationVtGate) String() string { - return "DestinationVtGate()" -} - // // DestinationNone // diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index a455969631e..ef94fc43afa 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -22,7 +22,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" - "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/srvtopo" @@ -43,45 +42,6 @@ type Delete struct { noInputs } -// MarshalJSON serializes the Delete into a JSON representation. -// It's used for testing and diagnostics. -func (del *Delete) MarshalJSON() ([]byte, error) { - var tname, vindexName, ksidVindexName string - if del.Table != nil { - tname = del.Table.Name.String() - } - if del.Vindex != nil { - vindexName = del.Vindex.String() - } - if del.KsidVindex != nil { - ksidVindexName = del.KsidVindex.String() - } - marshalDelete := struct { - Opcode string - Keyspace *vindexes.Keyspace `json:",omitempty"` - Query string `json:",omitempty"` - Vindex string `json:",omitempty"` - Values []sqltypes.PlanValue `json:",omitempty"` - Table string `json:",omitempty"` - OwnedVindexQuery string `json:",omitempty"` - KsidVindex string `json:",omitempty"` - MultiShardAutocommit bool `json:",omitempty"` - QueryTimeout int `json:",omitempty"` - }{ - Opcode: del.RouteType(), - Keyspace: del.Keyspace, - Query: del.Query, - Vindex: vindexName, - Values: del.Values, - Table: tname, - OwnedVindexQuery: del.OwnedVindexQuery, - KsidVindex: ksidVindexName, - MultiShardAutocommit: del.MultiShardAutocommit, - QueryTimeout: del.QueryTimeout, - } - return jsonutil.MarshalNoEscape(marshalDelete) -} - var delName = map[DMLOpcode]string{ Unsharded: "DeleteUnsharded", Equal: "DeleteEqual", @@ -238,10 +198,17 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] } func (del *Delete) description() PrimitiveDescription { - other := map[string]string{ + other := map[string]interface{}{ "Query": del.Query, "TableName": del.GetTableName(), } + if del.Vindex != nil { + other["Vindex"] = del.Vindex.String() + } + if del.KsidVindex != nil { + other["KsidVindexName"] = del.KsidVindex.String() + } + return PrimitiveDescription{ OperatorType: "Delete", Keyspace: del.Keyspace, diff --git a/go/vt/vtgate/engine/insert.go b/go/vt/vtgate/engine/insert.go index c26e90fabd2..df7c0e3f326 100644 --- a/go/vt/vtgate/engine/insert.go +++ b/go/vt/vtgate/engine/insert.go @@ -25,7 +25,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" - "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/sqlparser" @@ -117,41 +116,6 @@ func NewInsert(opcode InsertOpcode, keyspace *vindexes.Keyspace, vindexValues [] } } -// MarshalJSON serializes the Insert into a JSON representation. -// It's used for testing and diagnostics. -func (ins *Insert) MarshalJSON() ([]byte, error) { - var tname string - if ins.Table != nil { - tname = ins.Table.Name.String() - } - marshalInsert := struct { - Opcode InsertOpcode - Keyspace *vindexes.Keyspace `json:",omitempty"` - Query string `json:",omitempty"` - Values []sqltypes.PlanValue `json:",omitempty"` - Table string `json:",omitempty"` - Generate *Generate `json:",omitempty"` - Prefix string `json:",omitempty"` - Mid []string `json:",omitempty"` - Suffix string `json:",omitempty"` - MultiShardAutocommit bool `json:",omitempty"` - QueryTimeout int `json:",omitempty"` - }{ - Opcode: ins.Opcode, - Keyspace: ins.Keyspace, - Query: ins.Query, - Values: ins.VindexValues, - Table: tname, - Generate: ins.Generate, - Prefix: ins.Prefix, - Mid: ins.Mid, - Suffix: ins.Suffix, - MultiShardAutocommit: ins.MultiShardAutocommit, - QueryTimeout: ins.QueryTimeout, - } - return jsonutil.MarshalNoEscape(marshalInsert) -} - // Generate represents the instruction to generate // a value from a sequence. type Generate struct { @@ -616,11 +580,11 @@ func insertVarName(col sqlparser.ColIdent, rowNum int) string { } func (ins *Insert) description() PrimitiveDescription { - other := map[string]string{ + other := map[string]interface{}{ "Query": ins.Query, "TableName": ins.GetTableName(), - "MultiShardAutocommit": strconv.FormatBool(ins.MultiShardAutocommit), - "QueryTimeout": strconv.Itoa(ins.QueryTimeout), + "MultiShardAutocommit": ins.MultiShardAutocommit, + "QueryTimeout": ins.QueryTimeout, } return PrimitiveDescription{ OperatorType: "Insert", diff --git a/go/vt/vtgate/engine/join.go b/go/vt/vtgate/engine/join.go index db897f5cafa..c5fb9add298 100644 --- a/go/vt/vtgate/engine/join.go +++ b/go/vt/vtgate/engine/join.go @@ -21,8 +21,6 @@ import ( "strings" "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" - querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -258,14 +256,13 @@ func combineVars(bv1, bv2 map[string]*querypb.BindVariable) map[string]*querypb. } func (jn *Join) description() PrimitiveDescription { - other := map[string]string{ + other := map[string]interface{}{ "TableName": jn.GetTableName(), "JoinColumnIndexes": strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jn.Cols)), ","), "[]"), } return PrimitiveDescription{ - OperatorType: "Join", - Variant: jn.Opcode.String(), - TargetDestination: key.DestinationVtGate{}, - Other: other, + OperatorType: "Join", + Variant: jn.Opcode.String(), + Other: other, } } diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index 80ad701acff..97b63c50d24 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -17,12 +17,9 @@ limitations under the License. package engine import ( - "encoding/json" "fmt" "io" - "vitess.io/vitess/go/vt/key" - "vitess.io/vitess/go/sqltypes" querypb "vitess.io/vitess/go/vt/proto/query" @@ -37,23 +34,6 @@ type Limit struct { Input Primitive } -// MarshalJSON serializes the Limit into a JSON representation. -// It's used for testing and diagnostics. -func (l *Limit) MarshalJSON() ([]byte, error) { - marshalLimit := struct { - Opcode string - Count sqltypes.PlanValue - Offset sqltypes.PlanValue - Input Primitive - }{ - Opcode: "Limit", - Count: l.Count, - Offset: l.Offset, - Input: l.Input, - } - return json.Marshal(marshalLimit) -} - // RouteType returns a description of the query routing type used by the primitive func (l *Limit) RouteType() string { return l.Input.RouteType() @@ -204,18 +184,17 @@ func (l *Limit) fetchOffset(bindVars map[string]*querypb.BindVariable) (int, err } func (l *Limit) description() PrimitiveDescription { - other := map[string]string{} + other := map[string]interface{}{} if !l.Count.IsNull() { - other["Count"] = l.Count.Value.String() + other["Count"] = l.Count.Value } if !l.Offset.IsNull() { - other["Offset"] = l.Offset.Value.String() + other["Offset"] = l.Offset.Value } return PrimitiveDescription{ - OperatorType: "Limit", - Other: other, - TargetDestination: key.DestinationVtGate{}, + OperatorType: "Limit", + Other: other, } } diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index 852ad2f697d..6bc48e4838d 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -18,7 +18,6 @@ package engine import ( "container/heap" - "encoding/json" "fmt" "math" "reflect" @@ -26,7 +25,6 @@ import ( "strings" "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -44,23 +42,6 @@ type MemorySort struct { TruncateColumnCount int `json:",omitempty"` } -// MarshalJSON serializes the MemorySort into a JSON representation. -// It's used for testing and diagnostics. -func (ms *MemorySort) MarshalJSON() ([]byte, error) { - marshalMemorySort := struct { - Opcode string - MaxRows sqltypes.PlanValue - OrderBy []OrderbyParams - Input Primitive - }{ - Opcode: "MemorySort", - MaxRows: ms.UpperLimit, - OrderBy: ms.OrderBy, - Input: ms.Input, - } - return json.Marshal(marshalMemorySort) -} - // RouteType returns a description of the query routing type used by the primitive. func (ms *MemorySort) RouteType() string { return ms.Input.RouteType() @@ -190,15 +171,14 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int func (ms *MemorySort) description() PrimitiveDescription { orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) value := ms.UpperLimit.Value - other := map[string]string{"OrderBy": orderByIndexes} + other := map[string]interface{}{"OrderBy": orderByIndexes} if !value.IsNull() { other["UpperLimit"] = value.String() } return PrimitiveDescription{ - OperatorType: "Sort", - Variant: "Memory", - TargetDestination: key.DestinationVtGate{}, - Other: other, + OperatorType: "Sort", + Variant: "Memory", + Other: other, } } diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index 64a5376f66a..e894abeaa71 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -20,8 +20,6 @@ import ( "container/heap" "io" - "vitess.io/vitess/go/vt/key" - "golang.org/x/net/context" "vitess.io/vitess/go/sqltypes" @@ -158,15 +156,13 @@ func (ms *MergeSort) StreamExecute(vcursor VCursor, bindVars map[string]*querypb } func (ms *MergeSort) description() PrimitiveDescription { - orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) - other := map[string]string{ - "OrderBy": orderByIndexes, + other := map[string]interface{}{ + "OrderBy": ms.OrderBy, } return PrimitiveDescription{ - OperatorType: "Sort", - Variant: "Merge", - TargetDestination: key.DestinationVtGate{}, - Other: other, + OperatorType: "Sort", + Variant: "Merge", + Other: other, } } diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index c6ee9864371..aa44c335f7f 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -20,8 +20,6 @@ import ( "fmt" "strconv" - "vitess.io/vitess/go/vt/key" - "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/vterrors" @@ -416,15 +414,14 @@ func intToString(i interface{}) string { func (oa *OrderedAggregate) description() PrimitiveDescription { aggregates := GenericJoin(oa.Aggregates, aggregateParamsToString) groupBy := GenericJoin(oa.Keys, intToString) - other := map[string]string{ + other := map[string]interface{}{ "Aggregates": aggregates, "GroupBy": groupBy, "Distinct": strconv.FormatBool(oa.HasDistinct), } return PrimitiveDescription{ - OperatorType: "Aggregate", - Variant: "Ordered", - TargetDestination: key.DestinationVtGate{}, - Other: other, + OperatorType: "Aggregate", + Variant: "Ordered", + Other: other, } } diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index 4b2267041ab..84c7bb4c788 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -37,7 +37,7 @@ type PrimitiveDescription struct { // TargetTabletType specifies an explicit target destination tablet type // this is only used in conjunction with TargetDestination TargetTabletType topodatapb.TabletType - Other map[string]string + Other map[string]interface{} Inputs []PrimitiveDescription } @@ -88,12 +88,13 @@ func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) { return buf.Bytes(), nil } -func addMap(input map[string]string, buf *bytes.Buffer) error { - mk := make([]string, len(input)) - i := 0 - for k := range input { - mk[i] = k - i++ +func addMap(input map[string]interface{}, buf *bytes.Buffer) error { + var mk []string + for k, v := range input { + if v == "" || v == nil { + continue + } + mk = append(mk, k) } sort.Strings(mk) for _, k := range mk { diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index ca226de303a..61e0b6fed85 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -40,9 +40,9 @@ func TestCreateRoutePlanDescription(t *testing.T) { Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, TargetTabletType: topodatapb.TabletType_MASTER, - Other: map[string]string{ - "Query": route.Query, - "TableName": route.TableName, + Other: map[string]interface{}{ + "Query": route.Query, + "Table": route.TableName, }, Inputs: []PrimitiveDescription{}, } @@ -84,7 +84,7 @@ func TestPlanDescriptionWithInputs(t *testing.T) { expected := PrimitiveDescription{ OperatorType: "Limit", - Other: map[string]string{ + Other: map[string]interface{}{ "Count": "12", "Offset": "4", }, @@ -108,7 +108,7 @@ func getDescriptionFor(route *Route) PrimitiveDescription { Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, TargetTabletType: topodatapb.TabletType_MASTER, - Other: map[string]string{ + Other: map[string]interface{}{ "Query": route.Query, "TableName": route.TableName, }, diff --git a/go/vt/vtgate/engine/pullout_subquery.go b/go/vt/vtgate/engine/pullout_subquery.go index 3c0df478a17..9d77362f96b 100644 --- a/go/vt/vtgate/engine/pullout_subquery.go +++ b/go/vt/vtgate/engine/pullout_subquery.go @@ -19,8 +19,6 @@ package engine import ( "fmt" - "vitess.io/vitess/go/vt/key" - "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/vterrors" @@ -160,9 +158,8 @@ func (ps *PulloutSubquery) execSubquery(vcursor VCursor, bindVars map[string]*qu func (ps *PulloutSubquery) description() PrimitiveDescription { return PrimitiveDescription{ - OperatorType: "Subquery", - Variant: ps.Opcode.String(), - TargetDestination: key.DestinationVtGate{}, + OperatorType: "Subquery", + Variant: ps.Opcode.String(), } } diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 4c4103d7de9..8fc8c587dff 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -568,10 +568,19 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) } func (route *Route) description() PrimitiveDescription { - other := map[string]string{ - "Query": route.Query, - "Table": route.TableName, + + 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 + } + return PrimitiveDescription{ OperatorType: "Route", Variant: routeName[route.Opcode], diff --git a/go/vt/vtgate/engine/send.go b/go/vt/vtgate/engine/send.go index ec26a0aa8cb..e286ea241be 100644 --- a/go/vt/vtgate/engine/send.go +++ b/go/vt/vtgate/engine/send.go @@ -115,7 +115,7 @@ func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariabl } func (s *Send) description() PrimitiveDescription { - other := map[string]string{ + other := map[string]interface{}{ "Query": s.Query, "Table": s.GetTableName(), } diff --git a/go/vt/vtgate/engine/subquery.go b/go/vt/vtgate/engine/subquery.go index 4d3a665b113..412541aef81 100644 --- a/go/vt/vtgate/engine/subquery.go +++ b/go/vt/vtgate/engine/subquery.go @@ -18,7 +18,6 @@ package engine import ( "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -105,12 +104,11 @@ func (sq *Subquery) buildFields(inner *sqltypes.Result) []*querypb.Field { } func (sq *Subquery) description() PrimitiveDescription { - other := map[string]string{ - "Columns": GenericJoin(sq.Cols, intToString), + other := map[string]interface{}{ + "Columns": sq.Cols, } return PrimitiveDescription{ - OperatorType: "Subquery", - TargetDestination: key.DestinationVtGate{}, - Other: other, + OperatorType: "Subquery", + Other: other, } } diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index 7d10b895033..afcdebf158a 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -19,7 +19,6 @@ package engine import ( "fmt" "sort" - "strings" "time" topodatapb "vitess.io/vitess/go/vt/proto/topodata" @@ -274,10 +273,13 @@ func (upd *Update) description() PrimitiveDescription { changedVindexes = append(changedVindexes, vindex) } sort.Strings(changedVindexes) - other := map[string]string{ - "Query": upd.Query, - "TableName": upd.GetTableName(), - "Vindexes": strings.Join(changedVindexes, ", "), + other := map[string]interface{}{ + "Query": upd.Query, + "Table": upd.GetTableName(), + } + + if len(changedVindexes) > 0 { + other["Vindex"] = changedVindexes } return PrimitiveDescription{ OperatorType: "Update", diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt index f32709be96c..7ff0da298af 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt @@ -11,6 +11,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select count(*), col from unsharded where 1 != 1", "Query": "select count(*), col from unsharded", "Table": "unsharded" } @@ -28,8 +29,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*), col from user where 1 != 1", "Query": "select count(*), col from user where id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -45,6 +51,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select fun(1), col from user where 1 != 1", "Query": "select fun(1), col from user", "Table": "user" } @@ -62,6 +69,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, id from user where 1 != 1", "Query": "select distinct col1, id from user", "Table": "user" } @@ -79,6 +87,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, id from user where 1 != 1 group by col1", "Query": "select distinct col1, id from user group by col1", "Table": "user" } @@ -91,7 +100,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", "GroupBy": "1, 4, 3", @@ -104,6 +112,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*), a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", "Query": "select count(*), a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by a asc, textcol1 asc, b asc", "Table": "user" } @@ -118,13 +127,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "0 ASC, 4 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", "GroupBy": "1, 4, 3", @@ -137,6 +144,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", "Query": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by textcol1 asc, a asc, b asc", "Table": "user" } @@ -153,10 +161,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -166,6 +172,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select count(*) from user", "Table": "user" } @@ -180,10 +187,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "sum(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -193,6 +198,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select sum(col) from user where 1 != 1", "Query": "select sum(col) from user", "Table": "user" } @@ -207,10 +213,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "min(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -220,6 +224,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select min(col) from user where 1 != 1", "Query": "select min(col) from user", "Table": "user" } @@ -234,10 +239,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "max(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -247,6 +250,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select max(col) from user where 1 != 1", "Query": "select max(col) from user", "Table": "user" } @@ -261,8 +265,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", - "Aggregates": "", "Distinct": "false", "GroupBy": "0, 1, 0", "Inputs": [ @@ -274,6 +276,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1", "Query": "select distinct col1, col2 from user group by col1 order by col1 asc, col2 asc, col1 asc", "Table": "user" } @@ -288,7 +291,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_unsharded", "Inputs": [ @@ -300,6 +302,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.a from user where 1 != 1", "Query": "select user.a from user", "Table": "user" }, @@ -310,6 +313,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select t.b from (select count(*) as b from unsharded where 1 != 1) as t where 1 != 1", "Query": "select t.b from (select count(*) as b from unsharded) as t", "Table": "unsharded" } @@ -329,6 +333,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id, count(*) from user where 1 != 1 group by id", "Query": "select id, count(*) from user group by id", "Table": "user" } @@ -346,6 +351,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id, col, count(*) from user where 1 != 1 group by id, col", "Query": "select id, col, count(*) from user group by id, col", "Table": "user" } @@ -358,7 +364,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", "GroupBy": "0", @@ -371,6 +376,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", "Query": "select col, count(*) from user group by col order by col asc", "Table": "user" } @@ -385,7 +391,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", "GroupBy": "0", @@ -398,6 +403,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select name, count(*) from user where 1 != 1 group by name", "Query": "select name, count(*) from user group by name order by name asc", "Table": "user" } @@ -417,6 +423,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id, 1 + count(*) from user where 1 != 1 group by id", "Query": "select id, 1 + count(*) from user group by id", "Table": "user" } @@ -434,6 +441,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id as val, 1 + count(*) from user where 1 != 1 group by val", "Query": "select id as val, 1 + count(*) from user group by val", "Table": "user" } @@ -451,6 +459,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select val as id, 1 + count(*) from user where 1 != 1 group by user.id", "Query": "select val as id, 1 + count(*) from user group by user.id", "Table": "user" } @@ -468,6 +477,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select *, id, 1 + count(*) from user where 1 != 1 group by id", "Query": "select *, id, 1 + count(*) from user group by id", "Table": "user" } @@ -485,8 +495,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -497,16 +512,15 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "0", + "Columns": [ + 0 + ], "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -516,6 +530,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) as a from user where 1 != 1", "Query": "select count(*) as a from user", "Table": "user" } @@ -532,10 +547,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -545,6 +558,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id, count(*) from user where 1 != 1", "Query": "select id, count(*) from user", "Table": "user" } @@ -559,8 +573,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", - "Aggregates": "", "Distinct": "false", "GroupBy": "0", "Inputs": [ @@ -572,6 +584,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select distinct col from user order by col asc", "Table": "user" } @@ -586,8 +599,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", - "Aggregates": "", "Distinct": "false", "GroupBy": "0", "Inputs": [ @@ -599,6 +610,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1 group by col", "Query": "select col from user group by col order by col asc", "Table": "user" } @@ -618,6 +630,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id, count(distinct col) from user where 1 != 1 group by id", "Query": "select id, count(distinct col) from user group by id", "Table": "user" } @@ -630,7 +643,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", "GroupBy": "0", @@ -643,6 +655,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col, count(distinct id) from user where 1 != 1 group by col", "Query": "select col, count(distinct id) from user group by col order by col asc", "Table": "user" } @@ -657,7 +670,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count_distinct(1) AS count(distinct col2)", "Distinct": "true", "GroupBy": "0", @@ -670,6 +682,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" } @@ -684,10 +697,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count_distinct(0) AS count(distinct col2)", "Distinct": "true", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -697,6 +708,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col2 from user where 1 != 1 group by col2", "Query": "select col2 from user group by col2 order by col2 asc", "Table": "user" } @@ -711,7 +723,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count_distinct(1) AS c2", "Distinct": "true", "GroupBy": "0", @@ -724,6 +735,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" } @@ -738,7 +750,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "sum_distinct(1) AS sum(distinct col2)", "Distinct": "true", "GroupBy": "0", @@ -751,6 +762,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" } @@ -765,7 +777,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "min(1)", "Distinct": "false", "GroupBy": "0", @@ -778,6 +789,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, min(distinct col2) from user where 1 != 1 group by col1", "Query": "select col1, min(distinct col2) from user group by col1 order by col1 asc", "Table": "user" } @@ -792,13 +804,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "1 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count_distinct(1) AS k", "Distinct": "true", "GroupBy": "0", @@ -811,6 +821,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" } @@ -831,7 +842,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "1, 0", @@ -844,6 +854,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by b, a", "Query": "select a, b, count(*) from user group by b, a order by b asc, a asc", "Table": "user" } @@ -858,7 +869,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "1, 0", @@ -871,6 +881,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by 2, 1", "Query": "select a, b, count(*) from user group by 2, 1 order by b asc, a asc", "Table": "user" } @@ -885,8 +896,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", - "Aggregates": "", "Distinct": "false", "GroupBy": "0", "Inputs": [ @@ -898,6 +907,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1 group by 1", "Query": "select col from user group by 1 order by col asc", "Table": "user" } @@ -916,10 +926,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -929,6 +937,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select count(*) from user", "Table": "user" } @@ -947,7 +956,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(4)", "Distinct": "false", "GroupBy": "0, 1, 2", @@ -960,6 +968,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1 asc, 2 asc, 3 asc", "Table": "user" } @@ -974,7 +983,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(4)", "Distinct": "false", "GroupBy": "0, 1, 2", @@ -987,6 +995,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a asc, b asc, c asc", "Table": "user" } @@ -1001,7 +1010,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(4)", "Distinct": "false", "GroupBy": "0, 1, 2, 3", @@ -1014,6 +1022,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3, 4", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d asc, b asc, a asc, c asc", "Table": "user" } @@ -1028,7 +1037,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(4)", "Distinct": "false", "GroupBy": "2, 1, 0, 3", @@ -1041,6 +1049,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 3, 2, 1, 4", "Query": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d asc, b asc, a asc, c asc", "Table": "user" } @@ -1055,7 +1064,6 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(3)", "Distinct": "false", "GroupBy": "2, 1, 0", @@ -1068,6 +1076,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, c, count(*) from user where 1 != 1 group by 3, 2, 1", "Query": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b asc", "Table": "user" } @@ -1086,13 +1095,11 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", "GroupBy": "0", @@ -1105,6 +1112,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", "Query": "select col, count(*) from user group by col order by col asc limit :__upper_limit", "Table": "user" } @@ -1126,8 +1134,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1142,6 +1155,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select id, count(*) from unsharded as route2 where 1 != 1 group by id", "Query": "select id, count(*) from unsharded as route2 group by id", "Table": "unsharded" } @@ -1158,6 +1172,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select id, a from unsharded as route2 where 1 != 1", "Query": "select distinct id, a from unsharded as route2", "Table": "unsharded" } @@ -1174,6 +1189,7 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select col from ref where 1 != 1", "Query": "select col from ref order by col asc", "Table": "ref" } diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt index 680b157b801..be39902e355 100644 --- a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt @@ -10,8 +10,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", - "Query": "select count(*), col from unsharded", - "Table": "" + "Query": "select count(*), col from unsharded" } } @@ -27,8 +26,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", - "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1", - "Table": "" + "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1" } } @@ -44,8 +42,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", - "Query": "delete from USER where ID = 42", - "Table": "" + "Query": "delete from USER where ID = 42" } } @@ -61,7 +58,6 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", - "Query": "insert into USER(ID, NAME) values (42, 'ms X')", - "Table": "" + "Query": "insert into USER(ID, NAME) values (42, 'ms X')" } } diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt index a6b58289fd2..793a0cc99be 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt @@ -18,9 +18,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update m1 set val = 1", - "TableName": "", - "Vindexes": "" + "Query": "update m1 set val = 1" } } @@ -36,9 +34,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded set val = 1", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded set val = 1" } } @@ -54,9 +50,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded set col = (select col from unsharded limit 1)", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded set col = (select col from unsharded limit 1)" } } @@ -72,9 +66,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded set col = (select id from unsharded union select id from unsharded)", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded set col = (select id from unsharded union select id from unsharded)" } } @@ -90,9 +82,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded set col = (select id from unsharded as a join unsharded as b on a.id = b.id)", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded set col = (select id from unsharded as a join unsharded as b on a.id = b.id)" } } @@ -108,9 +98,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000" } } @@ -127,8 +115,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user as route1 set a = 1 where id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -144,9 +131,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded_a set a = (select a from unsharded as route2)", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded_a set a = (select a from unsharded as route2)" } } @@ -162,8 +147,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete from unsharded", - "TableName": "" + "Query": "delete from unsharded" } } @@ -180,8 +164,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -198,8 +181,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user as user_alias set val = 1 where user_alias.id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -216,8 +198,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -234,8 +215,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1 where name = 'foo' and id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -252,8 +232,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", - "TableName": "user_metadata", - "Vindexes": "email_user_map" + "Table": "user_metadata", + "Vindex": [ + "email_user_map" + ] } } @@ -274,8 +256,11 @@ }, "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", - "TableName": "user_metadata", - "Vindexes": "address_user_map, email_user_map" + "Table": "user_metadata", + "Vindex": [ + "address_user_map", + "email_user_map" + ] } } @@ -292,8 +277,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", - "TableName": "user_metadata", - "Vindexes": "email_user_map" + "Table": "user_metadata", + "Vindex": [ + "email_user_map" + ] } } @@ -310,8 +297,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = id2 and id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -328,8 +314,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -345,8 +330,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user where id = 1", - "TableName": "user" + "TableName": "user", + "Vindex": "user_index" } } @@ -362,8 +349,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete a from unsharded_a as a, unsharded_b as b where a.id = b.id and b.val = 1", - "TableName": "" + "Query": "delete a from unsharded_a as a, unsharded_b as b where a.id = b.id and b.val = 1" } } @@ -379,8 +365,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete a from unsharded_a as a join unsharded_b as b on a.id = b.id where b.val = 1", - "TableName": "" + "Query": "delete a from unsharded_a as a join unsharded_b as b on a.id = b.id where b.val = 1" } } @@ -396,8 +381,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000", - "TableName": "" + "Query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000" } } @@ -413,8 +397,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user as route1 where id = 1", - "TableName": "user" + "TableName": "user", + "Vindex": "user_index" } } @@ -430,8 +416,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete from unsharded_a where a = (select a from unsharded as route2)", - "TableName": "" + "Query": "delete from unsharded_a where a = (select a from unsharded as route2)" } } @@ -448,8 +433,7 @@ }, "TargetTabletType": "MASTER", "Query": "update music set val = 1 where id = 1", - "TableName": "music", - "Vindexes": "" + "Table": "music" } } @@ -465,9 +449,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded_a as a join unsharded_b as b on a.id = b.id set a.val = 'foo' where b.val = 1", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded_a as a join unsharded_b as b on a.id = b.id set a.val = 'foo' where b.val = 1" } } @@ -483,9 +465,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded_a as a, unsharded_b as b set a.val = 'foo' where a.id = b.id and b.val = 1", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded_a as a, unsharded_b as b set a.val = 'foo' where a.id = b.id and b.val = 1" } } @@ -501,8 +481,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from music where id = 1", - "TableName": "music" + "TableName": "music", + "Vindex": "music_user_map" } } @@ -519,7 +501,8 @@ }, "TargetTabletType": "MASTER", "Query": "delete from music_extra where user_id = 1", - "TableName": "music_extra" + "TableName": "music_extra", + "Vindex": "user_index" } } @@ -535,9 +518,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded values ()", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -554,9 +537,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded values (1, 2)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -573,9 +556,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded values (1, 2) on duplicate key update x = 3", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -592,9 +575,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded_authoritative(col1, col2) values (:__seq0, 1)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_authoritative" } } @@ -611,9 +594,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into music(user_id, id) values (:_user_id0, :_id0) on duplicate key update user_id = values(user_id)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "music" } } @@ -630,9 +613,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into music(user_id, id) values (:_user_id0, :_id0), (:_user_id1, :_id1) on duplicate key update user_id = values(user_id)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "music" } } @@ -649,9 +632,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded select id from unsharded_auto", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -668,9 +651,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded select id from unsharded join unsharded_auto", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -691,9 +674,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa')", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -710,9 +693,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(val, id) values ('aa', :__seq0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -729,9 +712,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(val, id) values (false, :__seq0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -748,9 +731,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -767,9 +750,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded values ((select 1 from dual), 1)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -786,9 +769,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -809,9 +792,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into authoritative(user_id, col1, col2) values (:_user_id0, 2, 3)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "authoritative" } } @@ -832,9 +815,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -851,9 +834,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert ignore into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -870,9 +853,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0) on duplicate key update col = 2", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -889,9 +872,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -908,9 +891,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(nonid, id, Name, Costly) values (2, :_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -927,9 +910,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, nonid, Name, Costly) values (:_Id0, 2, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -946,9 +929,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(nonid, id, Name, Costly) values (true, :_Id0, :_Name0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -965,9 +948,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(nonid, name, id, Costly) values (2, :_Name0, :_Id0, :_Costly0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -984,9 +967,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user_extra(nonid, extra_id, user_id) values (2, :__seq0, :_user_id0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user_extra" } } @@ -1003,9 +986,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into `weird``name`(`a``b*c`, `b*c`) values (:_a_b_c0, 2)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "weird`name" } } @@ -1022,9 +1005,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded select 1 from dual union select 1 from dual", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1057,9 +1040,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -1076,9 +1059,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "QueryTimeout": "1", + "QueryTimeout": 1, "TableName": "user" } } @@ -1095,9 +1078,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "true", + "MultiShardAutocommit": true, "Query": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "user" } } @@ -1118,9 +1101,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "replace into unsharded values (1, 2)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1137,9 +1120,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "replace into unsharded select id from unsharded_auto", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1160,9 +1143,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa')", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1179,9 +1162,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(val, id) values ('aa', :__seq0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1198,9 +1181,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1221,9 +1204,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "multicolvin" } } @@ -1240,9 +1223,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into overlap_vindex(kid, column_a, column_b) values (:_kid0, :_column_a0, 3)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "overlap_vindex" } } @@ -1259,9 +1242,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0), (:_column_a1, :_column_b1, :_column_c1, :_kid1)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "multicolvin" } } @@ -1278,8 +1261,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "kid_index", "Query": "delete from multicolvin where kid = 1", - "TableName": "multicolvin" + "TableName": "multicolvin", + "Vindex": "kid_index" } } @@ -1296,8 +1281,10 @@ }, "TargetTabletType": "MASTER", "Query": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", - "TableName": "multicolvin", - "Vindexes": "colb_colc_map" + "Table": "multicolvin", + "Vindex": [ + "colb_colc_map" + ] } } @@ -1314,8 +1301,11 @@ }, "TargetTabletType": "MASTER", "Query": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", - "TableName": "multicolvin", - "Vindexes": "cola_map, colb_colc_map" + "Table": "multicolvin", + "Vindex": [ + "cola_map", + "colb_colc_map" + ] } } @@ -1332,8 +1322,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1350,8 +1339,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1368,8 +1356,7 @@ }, "TargetTabletType": "MASTER", "Query": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1386,8 +1373,7 @@ }, "TargetTabletType": "MASTER", "Query": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1404,8 +1390,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where id between 1 and 2", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1422,8 +1407,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where user_id in (1, 2)", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1440,8 +1424,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where name = 'foo'", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1458,8 +1441,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where id in (1, 2)", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1476,8 +1458,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user_extra set val = 1 where name = 'foo' or id = 1", - "TableName": "user_extra", - "Vindexes": "" + "Table": "user_extra" } } @@ -1612,9 +1593,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)", - "TableName": "", - "Vindexes": "" + "Query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)" } } @@ -1630,8 +1609,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)", - "TableName": "" + "Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)" } } @@ -1648,8 +1626,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user set name = null where id = 1", - "TableName": "user", - "Vindexes": "name_user_map" + "Table": "user", + "Vindex": [ + "name_user_map" + ] } } @@ -1665,9 +1645,9 @@ "Sharded": false }, "TargetTabletType": "MASTER", - "MultiShardAutocommit": "false", + "MultiShardAutocommit": false, "Query": "insert into unsharded values (:__lastInsertId, 2)", - "QueryTimeout": "0", + "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1685,8 +1665,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user set name = null where id in (1, 2, 3)", - "TableName": "user", - "Vindexes": "name_user_map" + "Table": "user", + "Vindex": [ + "name_user_map" + ] } } @@ -1703,8 +1685,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user set name = null", - "TableName": "user", - "Vindexes": "name_user_map" + "Table": "user", + "Vindex": [ + "name_user_map" + ] } } @@ -1721,8 +1705,10 @@ }, "TargetTabletType": "MASTER", "Query": "update user set name = null where id + 1 = 2", - "TableName": "user", - "Vindexes": "name_user_map" + "Table": "user", + "Vindex": [ + "name_user_map" + ] } } @@ -1738,6 +1724,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user where id in (1, 2, 3)", "TableName": "user" } @@ -1755,6 +1742,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user where id + 1 = 2", "TableName": "user" } @@ -1772,6 +1760,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user", "TableName": "user" } @@ -1789,8 +1778,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete music from music where id = 1", - "TableName": "music" + "TableName": "music", + "Vindex": "music_user_map" } } @@ -1807,8 +1798,7 @@ }, "TargetTabletType": "MASTER", "Query": "update user set val = 1", - "TableName": "user", - "Vindexes": "" + "Table": "user" } } @@ -1824,6 +1814,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "KsidVindexName": "user_index", "Query": "delete from user", "TableName": "user" } @@ -1842,7 +1833,9 @@ }, "TargetTabletType": "MASTER", "Query": "update multicolvin set column_c = 2 where kid = 1", - "TableName": "multicolvin", - "Vindexes": "colb_colc_map" + "Table": "multicolvin", + "Vindex": [ + "colb_colc_map" + ] } } diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt index 4d755e097b3..bdfac478e36 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt @@ -10,6 +10,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user", "Table": "user" } @@ -27,8 +28,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -44,6 +50,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 5 + 5", "Table": "user" } @@ -61,8 +68,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id = 5 and user_id = 4", - "Table": "music" + "Table": "music", + "Values": [ + 4 + ], + "Vindex": "user_index" } } @@ -78,8 +90,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where costly = 'aa' and name = 'bb'", - "Table": "user" + "Table": "user", + "Values": [ + "bb" + ], + "Vindex": "name_user_map" } } @@ -95,8 +112,16 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where costly in ('aa', 'bb') and name in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + [ + "aa", + "bb" + ] + ], + "Vindex": "name_user_map" } } @@ -112,6 +137,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name in (col, 'bb')", "Table": "user" } @@ -129,8 +155,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name = :a", - "Table": "user" + "Table": "user", + "Values": [ + ":a" + ], + "Vindex": "name_user_map" } } @@ -146,8 +177,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name = 18446744073709551615", - "Table": "user" + "Table": "user", + "Values": [ + 18446744073709551615 + ], + "Vindex": "name_user_map" } } @@ -163,8 +199,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + "::list" + ], + "Vindex": "name_user_map" } } @@ -180,8 +221,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -197,8 +243,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -214,8 +265,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -231,8 +287,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -243,7 +304,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_user_extra", "Inputs": [ @@ -255,8 +315,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -266,6 +331,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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", "Table": "user_extra" } @@ -280,7 +346,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_user_extra", "Inputs": [ @@ -292,8 +357,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -303,8 +373,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user_extra", + "Values": [ + 5 + ], + "Vindex": "user_index" } ] } @@ -317,7 +392,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_user_extra", "Inputs": [ @@ -329,6 +403,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -340,8 +415,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user_extra", + "Values": [ + ":user_col" + ], + "Vindex": "user_index" } ] } @@ -354,7 +434,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_user_extra", "Inputs": [ @@ -366,6 +445,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where 1 = 1", "Table": "user" }, @@ -377,6 +457,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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", "Table": "user_extra" } @@ -396,8 +477,16 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.col = 5 and user.id in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + [ + 1, + 2 + ] + ], + "Vindex": "user_index" } } @@ -413,8 +502,16 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + [ + 1, + 2 + ] + ], + "Vindex": "user_index" } } @@ -430,8 +527,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + "aa" + ], + "Vindex": "name_user_map" } } @@ -447,8 +549,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + "aa" + ], + "Vindex": "name_user_map" } } @@ -464,8 +571,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -481,8 +593,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -498,6 +615,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "Table": "user" } @@ -510,7 +628,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_unsharded", "Inputs": [ @@ -522,6 +639,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" }, @@ -532,6 +650,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded where unsharded.id = :user_id", "Table": "unsharded" } @@ -551,8 +670,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user as route1 where 1 != 1", "Query": "select col from user as route1 where id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -568,8 +692,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user_metadata as route1 where 1 != 1", "Query": "select col from user_metadata as route1 where email = 'aaa'", - "Table": "user_metadata" + "Table": "user_metadata", + "Values": [ + "aaa" + ], + "Vindex": "email_user_map" } } @@ -584,8 +713,8 @@ "Name": "main", "Sharded": false }, - "Query": "select * from information_schema.a where id in (select * from information_schema.b)", - "Table": "" + "FieldQuery": "select * from information_schema.a where 1 != 1", + "Query": "select * from information_schema.a where id in (select * from information_schema.b)" } } @@ -596,7 +725,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_extra_user", "Inputs": [ @@ -608,6 +736,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra", "Table": "user_extra" }, @@ -619,8 +748,16 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.m from user as u where 1 != 1", "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" + "Table": "user", + "Values": [ + [ + ":user_extra_col", + 1 + ] + ], + "Vindex": "user_index" } ] } @@ -633,7 +770,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_extra_user", "Inputs": [ @@ -645,6 +781,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" }, @@ -656,8 +793,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } ] } @@ -670,7 +812,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_extra_user", "Inputs": [ @@ -682,6 +823,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra", "Table": "user_extra" }, @@ -693,8 +835,16 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.m from user as u where 1 != 1", "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" + "Table": "user", + "Values": [ + [ + ":user_extra_col", + 1 + ] + ], + "Vindex": "user_index" } ] } @@ -712,6 +862,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "Table": "user" } @@ -729,8 +880,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -746,8 +902,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + "aa" + ], + "Vindex": "user_index" } } @@ -763,8 +924,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + ":a" + ], + "Vindex": "user_index" } } @@ -784,6 +950,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id2 from user as uu where 1 != 1", "Query": "select id2 from user as uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "Table": "user" } @@ -797,7 +964,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -807,6 +973,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -818,8 +985,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1 = 1 and id in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + "::__sq1" + ], + "Vindex": "user_index" } ] } @@ -832,7 +1004,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutNotIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -842,6 +1013,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -853,6 +1025,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1 = 0 or id not in ::__sq1", "Table": "user" } @@ -867,7 +1040,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutExists", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -877,6 +1049,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -888,6 +1061,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1", "Table": "user" } @@ -902,7 +1076,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -912,6 +1085,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -923,8 +1097,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where id = :__sq1", - "Table": "user" + "Table": "user", + "Values": [ + ":__sq1" + ], + "Vindex": "user_index" } ] } @@ -937,12 +1116,10 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -952,6 +1129,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id3 from user where 1 != 1", "Query": "select id3 from user", "Table": "user" }, @@ -963,6 +1141,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id2 from user where 1 != 1", "Query": "select id2 from user where :__sq_has_values1 = 1 and id2 in ::__sq1", "Table": "user" } @@ -976,8 +1155,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id1 from user where 1 != 1", "Query": "select id1 from user where id = :__sq2", - "Table": "user" + "Table": "user", + "Values": [ + ":__sq2" + ], + "Vindex": "user_index" } ] } @@ -995,6 +1179,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = (select id from user as route2 where route2.id = user.id)", "Table": "user" } @@ -1007,7 +1192,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1016,6 +1200,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select id from unsharded as route2 where 1 != 1", "Query": "select id from unsharded as route2", "Table": "unsharded" }, @@ -1027,8 +1212,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = :__sq1", - "Table": "user" + "Table": "user", + "Values": [ + ":__sq1" + ], + "Vindex": "user_index" } ] } @@ -1046,8 +1236,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1063,6 +1258,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where database()", "Table": "user" } diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index 78f5b9378dc..72f779b5b70 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -10,6 +10,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" } @@ -26,6 +27,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select col from unsharded where 1 != 1", "Query": "select col from unsharded", "Table": "unsharded" } @@ -42,6 +44,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select next 2 values from seq where 1 != 1", "Query": "select next 2 values from seq", "Table": "seq" } @@ -58,6 +61,7 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select * from ref where 1 != 1", "Query": "select * from ref", "Table": "ref" } @@ -74,8 +78,8 @@ "Name": "main", "Sharded": false }, - "Query": "select col from information_schema.foo", - "Table": "" + "FieldQuery": "select col from information_schema.foo where 1 != 1", + "Query": "select col from information_schema.foo" } } @@ -90,6 +94,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m1 join unsharded as m2 where 1 != 1", "Query": "select m1.col from unsharded as m1 join unsharded as m2", "Table": "unsharded" } @@ -102,7 +107,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_music", "Inputs": [ @@ -114,6 +118,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" }, @@ -125,6 +130,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col from music where 1 != 1", "Query": "select music.col from music", "Table": "music" } @@ -144,6 +150,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user", "Table": "user" } @@ -161,6 +168,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user as a where 1 != 1", "Query": "select * from user as a", "Table": "user" } @@ -178,6 +186,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user as route1 where 1 != 1", "Query": "select * from user as route1", "Table": "user" } @@ -195,6 +204,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user as a where 1 != 1", "Query": "select * from user as a", "Table": "user" } @@ -212,6 +222,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user as master_redirect where 1 != 1", "Query": "select * from user as master_redirect", "Table": "user" } @@ -232,7 +243,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_music", "Inputs": [ @@ -244,6 +254,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" }, @@ -255,6 +266,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col from music where 1 != 1", "Query": "select music.col from music", "Table": "music" } @@ -273,6 +285,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select u1.a, u2.a from unsharded as u1, unsharded as u2 where 1 != 1", "Query": "select u1.a, u2.a from unsharded as u1, unsharded as u2", "Table": "unsharded" } @@ -289,8 +302,8 @@ "Name": "main", "Sharded": false }, - "Query": "select * from information_schema.a, information_schema.b", - "Table": "" + "FieldQuery": "select * from information_schema.a, information_schema.b where 1 != 1", + "Query": "select * from information_schema.a, information_schema.b" } } @@ -305,6 +318,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select u1.a, u2.a from unsharded as u1, unsharded as u2, unsharded as u3 where 1 != 1", "Query": "select u1.a, u2.a from unsharded as u1, unsharded as u2, unsharded as u3", "Table": "unsharded" } @@ -321,6 +335,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a = m2.b where 1 != 1", "Query": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a = m2.b", "Table": "unsharded" } @@ -333,7 +348,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_unsharded", "Inputs": [ @@ -345,6 +359,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.col, u.a from user as u where 1 != 1", "Query": "select u.col, u.a from user as u", "Table": "user" }, @@ -355,6 +370,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded as m where 1 != 1", "Query": "select 1 from unsharded as m where m.b = :u_a", "Table": "unsharded" } @@ -369,14 +385,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_unsharded_unsharded", "Inputs": [ { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_unsharded", "Inputs": [ @@ -388,6 +402,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -398,6 +413,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m1 where 1 != 1", "Query": "select m1.col from unsharded as m1 where m1.co = :user_col", "Table": "unsharded" } @@ -410,6 +426,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded as m2 where 1 != 1", "Query": "select 1 from unsharded as m2 where m2.col = :m1_col", "Table": "unsharded" } @@ -424,7 +441,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra_unsharded", "Inputs": [ @@ -436,14 +452,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", - "JoinColumnIndexes": "", "TableName": "user_extra_unsharded", "Inputs": [ { @@ -454,6 +469,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.col from user_extra as e where 1 != 1", "Query": "select e.col from user_extra as e where e.col = :user_col", "Table": "user_extra" }, @@ -464,6 +480,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded as m1 where 1 != 1", "Query": "select 1 from unsharded as m1 where m1.col = :e_col", "Table": "unsharded" } @@ -484,6 +501,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m2 left join unsharded as m1 on m1.a = m2.b where 1 != 1", "Query": "select m1.col from unsharded as m2 left join unsharded as m1 on m1.a = m2.b", "Table": "unsharded" } @@ -500,6 +518,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m3 left join (unsharded as m1 join unsharded as m2) on m1.a = m2.b where 1 != 1", "Query": "select m1.col from unsharded as m3 left join (unsharded as m1 join unsharded as m2) on m1.a = m2.b", "Table": "unsharded" } @@ -516,6 +535,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select m1.col from unsharded as m1 straight_join unsharded as m2 where 1 != 1", "Query": "select m1.col from unsharded as m1 straight_join unsharded as m2", "Table": "unsharded" } @@ -528,14 +548,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_unsharded_unsharded", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_unsharded", "Inputs": [ @@ -547,6 +565,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -557,6 +576,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded as m1 where 1 != 1", "Query": "select 1 from unsharded as m1", "Table": "unsharded" } @@ -569,6 +589,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded as m2 where 1 != 1", "Query": "select 1 from unsharded as m2", "Table": "unsharded" } @@ -583,7 +604,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_unsharded", "Inputs": [ @@ -595,6 +615,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -605,6 +626,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from (unsharded as m1 join unsharded as m2) where 1 != 1", "Query": "select 1 from (unsharded as m1 join unsharded as m2)", "Table": "unsharded" } @@ -619,7 +641,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_unsharded", "Inputs": [ @@ -631,14 +652,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", - "JoinColumnIndexes": "", "TableName": "user_unsharded", "Inputs": [ { @@ -649,6 +669,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u1 where 1 != 1", "Query": "select 1 from user as u1", "Table": "user" }, @@ -659,6 +680,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded where 1 != 1", "Query": "select 1 from unsharded", "Table": "unsharded" } @@ -680,6 +702,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user use index (a) where 1 != 1", "Query": "select user.col from user use index (a)", "Table": "user" } @@ -697,6 +720,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", "Table": "user" } @@ -714,6 +738,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", "Table": "user" } @@ -731,6 +756,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Table": "user" } @@ -748,6 +774,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join user_extra on user_extra.user_id = user.id where 1 != 1", "Query": "select user.col from user join user_extra on user_extra.user_id = user.id", "Table": "user" } @@ -765,8 +792,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -777,7 +809,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -789,6 +820,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col, user.id from user where 1 != 1", "Query": "select user.col, user.id from user", "Table": "user" }, @@ -800,6 +832,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where :user_id \u003c user_extra.user_id", "Table": "user_extra" } @@ -814,7 +847,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -826,8 +858,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -837,6 +874,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -851,7 +889,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -863,8 +900,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -874,6 +916,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -888,7 +931,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -900,6 +942,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col, user.id from user where 1 != 1", "Query": "select user.col, user.id from user", "Table": "user" }, @@ -911,6 +954,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :user_id", "Table": "user_extra" } @@ -925,7 +969,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_extra_user", "Inputs": [ @@ -937,6 +980,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.user_id from user_extra where 1 != 1", "Query": "select user_extra.user_id from user_extra", "Table": "user_extra" }, @@ -948,8 +992,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.name = :user_extra_user_id", - "Table": "user" + "Table": "user", + "Values": [ + ":user_extra_user_id" + ], + "Vindex": "name_user_map" } ] } @@ -967,6 +1016,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join ref where 1 != 1", "Query": "select user.col from user join ref", "Table": "user" } @@ -983,6 +1033,7 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select r1.col from ref as r1 join ref where 1 != 1", "Query": "select r1.col from ref as r1 join ref", "Table": "ref" } @@ -1000,6 +1051,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select ref.col from ref join user where 1 != 1", "Query": "select ref.col from ref join user", "Table": "user" } @@ -1017,6 +1069,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id where 1 != 1", "Query": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id", "Table": "user" } @@ -1029,7 +1082,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_user_extra", "Inputs": [ @@ -1040,6 +1092,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select route2.col from unsharded as route2 where 1 != 1", "Query": "select route2.col from unsharded as route2", "Table": "unsharded" }, @@ -1051,6 +1104,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -1070,8 +1124,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1087,8 +1146,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1104,8 +1168,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1125,6 +1194,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select t.id from user_extra join (select id from user where 1 != 1) as t on t.id = user_extra.user_id where 1 != 1", "Query": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Table": "user_extra" } @@ -1137,7 +1207,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -1149,8 +1218,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -1160,6 +1234,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :t_id", "Table": "user_extra" } @@ -1179,8 +1254,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1196,8 +1276,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from (select id, col from user_metadata as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from user_metadata as route1 where email = 'aaa') as t", - "Table": "user_metadata" + "Table": "user_metadata", + "Values": [ + "aaa" + ], + "Vindex": "email_user_map" } } @@ -1213,8 +1298,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1230,8 +1320,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -1246,8 +1341,8 @@ "Name": "main", "Sharded": false }, - "Query": "select * from information_schema.a where b = 10", - "Table": "" + "FieldQuery": "select * from information_schema.a where 1 != 1", + "Query": "select * from information_schema.a where b = 10" } } @@ -1262,8 +1357,8 @@ "Name": "main", "Sharded": false }, - "Query": "select * from information_schema.a where information_schema.a.b = 10", - "Table": "" + "FieldQuery": "select * from information_schema.a where 1 != 1", + "Query": "select * from information_schema.a where information_schema.a.b = 10" } } @@ -1274,7 +1369,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "_unsharded", "Inputs": [ @@ -1285,8 +1379,8 @@ "Name": "main", "Sharded": false }, - "Query": "select 1 from information_schema.a", - "Table": "" + "FieldQuery": "select 1 from information_schema.a where 1 != 1", + "Query": "select 1 from information_schema.a" }, { "OperatorType": "Route", @@ -1295,6 +1389,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.foo from unsharded where 1 != 1", "Query": "select unsharded.foo from unsharded", "Table": "unsharded" } @@ -1309,7 +1404,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_", "Inputs": [ @@ -1320,6 +1414,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.foo from unsharded where 1 != 1", "Query": "select unsharded.foo from unsharded", "Table": "unsharded" }, @@ -1330,8 +1425,8 @@ "Name": "main", "Sharded": false }, - "Query": "select 1 from information_schema.a", - "Table": "" + "FieldQuery": "select 1 from information_schema.a where 1 != 1", + "Query": "select 1 from information_schema.a" } ] } @@ -1344,20 +1439,20 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra_unsharded", "Inputs": [ { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "1, 0", + "Columns": [ + 1, + 0 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -1369,6 +1464,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id, user.col1 from user where 1 != 1", "Query": "select user.id, user.col1 from user", "Table": "user" }, @@ -1380,6 +1476,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -1394,6 +1491,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded where 1 != 1", "Query": "select 1 from unsharded where unsharded.col1 = :t_col1 and unsharded.id = :t_id", "Table": "unsharded" } @@ -1408,13 +1506,13 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "0", + "Columns": [ + 0 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -1426,6 +1524,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id, user.col1, user.col from user where 1 != 1", "Query": "select user.id, user.col1, user.col from user", "Table": "user" }, @@ -1437,6 +1536,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :user_col", "Table": "user_extra" } @@ -1453,7 +1553,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "unsharded_a_user_user_extra", "Inputs": [ @@ -1464,19 +1563,20 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded_a as ua where 1 != 1", "Query": "select 1 from unsharded_a as ua", "Table": "unsharded_a" }, { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "1", + "Columns": [ + 1 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -1488,6 +1588,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id, user.col1 from user where 1 != 1", "Query": "select user.id, user.col1 from user", "Table": "user" }, @@ -1499,6 +1600,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -1517,7 +1619,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1527,6 +1628,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -1537,6 +1639,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq1 where 1 != 1", "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq1", "Table": "unsharded_a" } @@ -1551,7 +1654,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1561,6 +1663,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -1571,6 +1674,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col + :__sq1 where 1 != 1", "Query": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col + :__sq1", "Table": "unsharded_a" } @@ -1585,7 +1689,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1595,6 +1698,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -1605,6 +1709,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq_has_values1 = 1 and unsharded_a.col in ::__sq1 where 1 != 1", "Query": "select unsharded_a.col from unsharded_a join unsharded_b on :__sq_has_values1 = 1 and unsharded_a.col in ::__sq1", "Table": "unsharded_a" } @@ -1619,7 +1724,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1629,13 +1733,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_user", "Inputs": [ @@ -1646,6 +1750,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.col from unsharded where 1 != 1", "Query": "select unsharded.col from unsharded", "Table": "unsharded" }, @@ -1657,6 +1762,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" } @@ -1674,7 +1780,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "LeftJoin", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_user", "Inputs": [ @@ -1685,13 +1790,13 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.col from unsharded where 1 != 1", "Query": "select unsharded.col from unsharded", "Table": "unsharded" }, { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1701,6 +1806,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -1712,6 +1818,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" } @@ -1729,14 +1836,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_user_unsharded_a", "Inputs": [ { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1746,13 +1851,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "unsharded_user", "Inputs": [ @@ -1763,6 +1868,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.col from unsharded where 1 != 1", "Query": "select unsharded.col from unsharded", "Table": "unsharded" }, @@ -1774,6 +1880,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" } @@ -1788,6 +1895,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select 1 from unsharded_a where 1 != 1", "Query": "select 1 from unsharded_a", "Table": "unsharded_a" } @@ -1802,7 +1910,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_unsharded", "Inputs": [ @@ -1814,6 +1921,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col1, user.col2 from user where 1 != 1", "Query": "select user.col1, user.col2 from user", "Table": "user" }, @@ -1824,6 +1932,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.col1 from unsharded where 1 != 1", "Query": "select unsharded.col1 from unsharded where unsharded.col2 = :user_col2", "Table": "unsharded" } @@ -1842,6 +1951,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select foo.col from foo where 1 != 1", "Query": "select foo.col from foo", "Table": "foo" } @@ -1859,6 +1969,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user join user_extra on user.ID = user_extra.User_Id where 1 != 1", "Query": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Table": "user" } @@ -1871,13 +1982,14 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "0, 0", + "Columns": [ + 0, + 0 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -1889,6 +2001,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" }, @@ -1900,6 +2013,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -1921,6 +2035,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select u1.a from unsharded as u1 join unsharded as u2 on database() where 1 != 1", "Query": "select u1.a from unsharded as u1 join unsharded as u2 on database()", "Table": "unsharded" } @@ -1937,6 +2052,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select :__lastInsertId as `last_insert_id()` from dual where 1 != 1", "Query": "select :__lastInsertId as `last_insert_id()` from dual", "Table": "dual" } @@ -1954,6 +2070,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select :__lastInsertId as `last_insert_id()` from user where 1 != 1", "Query": "select :__lastInsertId as `last_insert_id()` from user", "Table": "user" } @@ -1970,6 +2087,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select :__lastInsertId as `last_insert_id()` from unsharded where 1 != 1", "Query": "select :__lastInsertId as `last_insert_id()` from unsharded", "Table": "unsharded" } diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt index b99145e3781..3988de493be 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt @@ -6,13 +6,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "1 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "0", @@ -25,6 +23,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by a", "Query": "select a, b, count(*) from user group by a order by a asc", "Table": "user" } @@ -41,13 +40,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "2 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "0", @@ -60,6 +57,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" } @@ -76,13 +74,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "1 ASC, 0 ASC, 2 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "0", @@ -95,6 +91,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" } @@ -111,19 +108,16 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "2 DESC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "0", @@ -136,6 +130,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" } @@ -154,13 +149,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "0 ASC, 2 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(2)", "Distinct": "false", "GroupBy": "0", @@ -173,6 +166,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by 1 asc", "Table": "user" } @@ -190,13 +184,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "2 ASC, 1 ASC, 2 ASC", "Inputs": [ { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(1)", "Distinct": "false", "GroupBy": "2", @@ -209,6 +201,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select textcol1, count(*) as k, weight_string(textcol1) from user where 1 != 1 group by textcol1", "Query": "select textcol1, count(*) as k, weight_string(textcol1) from user group by textcol1 order by textcol1 asc, textcol1 asc", "Table": "user" } @@ -225,19 +218,18 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "0 ASC", "Inputs": [ { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "0", + "Columns": [ + 0 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -249,6 +241,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id, user.col from user where 1 != 1", "Query": "select user.id, user.col from user", "Table": "user" }, @@ -260,6 +253,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -278,13 +272,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "2 ASC", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -296,8 +288,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -307,8 +304,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col3 as c from music where 1 != 1", "Query": "select music.col3 as c from music where music.id = :user_id", - "Table": "music" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -323,13 +325,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "0 ASC, 2 DESC, 1 ASC", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -341,8 +341,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -352,8 +357,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", - "Table": "music" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -368,13 +378,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "3 ASC, 2 ASC", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1,-3", "TableName": "user_unsharded", "Inputs": [ @@ -386,6 +394,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", "Table": "user" }, @@ -396,6 +405,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select un.col2 from unsharded as un where 1 != 1", "Query": "select un.col2 from unsharded as un", "Table": "unsharded" } @@ -412,13 +422,11 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "3 ASC, 2 ASC", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1,2,-1,3", "TableName": "unsharded_user", "Inputs": [ @@ -429,6 +437,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select un.col2 from unsharded as un where 1 != 1", "Query": "select un.col2 from unsharded as un", "Table": "unsharded" }, @@ -440,6 +449,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", "Table": "user" } @@ -456,7 +466,6 @@ "Instructions": { "OperatorType": "Sort", "Variant": "Memory", - "TargetDestination": "VtGate()", "OrderBy": "2 ASC", "Inputs": [ { diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt index fffe18492d9..62b4ae349e6 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt @@ -10,6 +10,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col1 from user where 1 != 1", "Query": "select user.col1 from user having col2 = 2", "Table": "user" } @@ -26,7 +27,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -38,6 +38,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col1 from user where 1 != 1", "Query": "select user.col1 from user", "Table": "user" }, @@ -49,6 +50,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.col1 from user_extra where 1 != 1", "Query": "select user_extra.col1 from user_extra having user_extra.col1 = 2", "Table": "user_extra" } @@ -63,7 +65,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_user_extra", "Inputs": [ @@ -75,6 +76,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col1 as a, user.col2 from user where 1 != 1", "Query": "select user.col1 as a, user.col2 from user having 1 = 1 and a = 1 and a = user.col2", "Table": "user" }, @@ -86,6 +88,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.col3 from user_extra where 1 != 1", "Query": "select user_extra.col3 from user_extra having user_extra.col3 = 1", "Table": "user_extra" } @@ -100,7 +103,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -110,6 +112,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -121,8 +124,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user having :__sq_has_values1 = 1 and id in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + "::__sq1" + ], + "Vindex": "user_index" } ] } @@ -140,8 +148,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = 5 order by aa asc", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -157,8 +170,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = 1 order by 1 asc", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -174,6 +192,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by col asc", "Table": "user" } @@ -191,6 +210,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", "Query": "select user_id, col1, col2 from authoritative order by user_id asc", "Table": "authoritative" } @@ -208,6 +228,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_id, col1, col2, weight_string(col1) from authoritative where 1 != 1", "Query": "select user_id, col1, col2, weight_string(col1) from authoritative order by col1 asc", "Table": "authoritative" } @@ -225,6 +246,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, textcol1, b, weight_string(textcol1) from user where 1 != 1", "Query": "select a, textcol1, b, weight_string(textcol1) from user order by a asc, textcol1 asc, b asc", "Table": "user" } @@ -242,6 +264,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, user.textcol1, b, weight_string(user.textcol1) from user where 1 != 1", "Query": "select a, user.textcol1, b, weight_string(user.textcol1) from user order by a asc, textcol1 asc, b asc", "Table": "user" } @@ -259,6 +282,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user where 1 != 1", "Query": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user order by a asc, textcol1 asc, b asc, textcol2 asc", "Table": "user" } @@ -280,6 +304,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by null", "Table": "user" } @@ -292,7 +317,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -302,6 +326,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" }, @@ -313,6 +338,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by col asc", "Table": "user" } @@ -327,7 +353,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -339,8 +364,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -350,8 +380,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -364,7 +399,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -376,8 +410,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -387,8 +426,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", - "Table": "music" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -401,7 +445,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -413,8 +456,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -424,8 +472,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", - "Table": "music" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -438,7 +491,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -448,6 +500,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" }, @@ -459,6 +512,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by null", "Table": "user" } @@ -478,6 +532,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by RAND()", "Table": "user" } @@ -490,7 +545,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "user_music", "Inputs": [ @@ -502,8 +556,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -513,8 +572,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "music", + "Values": [ + ":user_id" + ], + "Vindex": "music_user_map" } ] } @@ -527,7 +591,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -537,6 +600,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" }, @@ -548,6 +612,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by rand()", "Table": "user" } @@ -567,8 +632,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by col asc", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -584,8 +654,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user where id = 5 order by user.col asc", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -601,8 +676,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by user.col asc", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -613,7 +693,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -625,6 +704,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u where u.col in (select * from user where user.id = u.id order by col asc)", "Table": "user" }, @@ -636,6 +716,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.col = :u_col", "Table": "user_extra" } @@ -671,8 +752,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -688,8 +774,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by -col1 asc", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -705,8 +796,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -722,8 +818,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -739,8 +840,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -756,8 +862,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -773,8 +884,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user_metadata as route1 where 1 != 1", "Query": "select col from user_metadata as route1 where email = 'aaa' order by col asc", - "Table": "user_metadata" + "Table": "user_metadata", + "Values": [ + "aaa" + ], + "Vindex": "email_user_map" } } @@ -790,8 +906,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1 from user where 1 != 1", "Query": "select col1 from user where id = 1 limit 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -803,13 +924,11 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(1)", + "Count": 1, "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -821,6 +940,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -832,6 +952,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" } @@ -848,8 +969,7 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(1)", + "Count": 1, "Inputs": [ { "OperatorType": "Route", @@ -859,6 +979,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user limit :__upper_limit", "Table": "user" } @@ -873,8 +994,7 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "NULL", + "Count": null, "Inputs": [ { "OperatorType": "Route", @@ -884,6 +1004,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user limit :__upper_limit", "Table": "user" } @@ -898,8 +1019,7 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(5)", + "Count": 5, "Inputs": [ { "OperatorType": "Route", @@ -909,6 +1029,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id1 = 4 and name1 = 'abc' limit :__upper_limit", "Table": "user" } @@ -923,13 +1044,11 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(1)", + "Count": 1, "Inputs": [ { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -939,6 +1058,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col1 from user where 1 != 1", "Query": "select col1 from user", "Table": "user" }, @@ -950,6 +1070,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 limit :__upper_limit", "Table": "user" } @@ -970,6 +1091,7 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select col from ref where 1 != 1", "Query": "select col from ref limit 1", "Table": "ref" } diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index 9868ddf8c57..de20905435c 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -10,6 +10,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" } @@ -27,6 +28,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" } @@ -44,6 +46,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user", "Table": "user" } @@ -61,6 +64,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "Table": "user" } @@ -73,10 +77,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -86,6 +88,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", "Table": "user" } @@ -100,8 +103,7 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Route", @@ -111,6 +113,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit :__upper_limit", "Table": "user" } @@ -130,6 +133,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user", "Table": "user" } @@ -142,10 +146,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -155,6 +157,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Table": "user" } @@ -169,10 +172,8 @@ "Instructions": { "OperatorType": "Aggregate", "Variant": "Ordered", - "TargetDestination": "VtGate()", "Aggregates": "count(0)", "Distinct": "false", - "GroupBy": "", "Inputs": [ { "OperatorType": "Route", @@ -182,6 +183,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Table": "user" } @@ -196,8 +198,7 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Route", @@ -207,6 +208,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit :__upper_limit", "Table": "user" } @@ -226,6 +228,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" } @@ -243,6 +246,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" } @@ -260,6 +264,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", "Query": "select user_id, col1, col2 from authoritative", "Table": "authoritative" } @@ -277,6 +282,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id where 1 != 1", "Query": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id", "Table": "authoritative" } @@ -298,6 +304,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a.user_id, a.col1, a.col2 from authoritative as a where 1 != 1", "Query": "select a.user_id, a.col1, a.col2 from authoritative as a", "Table": "authoritative" } @@ -315,6 +322,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from authoritative join user on authoritative.user_id = user.id where 1 != 1", "Query": "select * from authoritative join user on authoritative.user_id = user.id", "Table": "authoritative" } @@ -332,6 +340,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id where 1 != 1", "Query": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id", "Table": "authoritative" } @@ -349,6 +358,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select col from user join user_extra on user.id = user_extra.user_id", "Table": "user" } @@ -365,7 +375,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -377,6 +386,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user", "Table": "user" }, @@ -388,6 +398,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_id from user_extra where 1 != 1", "Query": "select user_id from user_extra", "Table": "user_extra" } @@ -406,6 +417,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select :__vtdbname as `database()` from dual where 1 != 1", "Query": "select :__vtdbname as `database()` from dual", "Table": "dual" } @@ -426,6 +438,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select :__lastInsertId as x from unsharded where 1 != 1", "Query": "select :__lastInsertId as x from unsharded", "Table": "unsharded" } @@ -442,6 +455,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select @@session.auto_increment_increment from dual where 1 != 1", "Query": "select @@session.auto_increment_increment from dual", "Table": "dual" } @@ -458,8 +472,13 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select * from pin_test where 1 != 1", "Query": "select * from pin_test", - "Table": "pin_test" + "Table": "pin_test", + "Values": [ + "\ufffd" + ], + "Vindex": "binary" } } @@ -474,6 +493,7 @@ "Name": "user", "Sharded": true }, + "FieldQuery": "select @@session.auto_increment_increment from dual where 1 != 1", "Query": "select @@session.auto_increment_increment from dual", "Table": "dual" } @@ -486,7 +506,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "user_user_extra", "Inputs": [ @@ -498,6 +517,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" }, @@ -509,6 +529,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" } @@ -523,7 +544,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -535,6 +555,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -546,6 +567,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" } @@ -560,7 +582,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -572,6 +593,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" }, @@ -583,6 +605,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.id + user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.id + user_extra.col from user_extra", "Table": "user_extra" } @@ -597,7 +620,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -609,6 +631,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col, user.col2 from user where 1 != 1", "Query": "select user.col, user.col2 from user", "Table": "user" }, @@ -620,6 +643,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" } @@ -634,7 +658,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -646,6 +669,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select /* comment */ user.col from user", "Table": "user" }, @@ -657,6 +681,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select /* comment */ 1 from user_extra", "Table": "user_extra" } @@ -671,7 +696,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_extra", "Inputs": [ @@ -683,6 +707,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user for update", "Table": "user" }, @@ -694,6 +719,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra for update", "Table": "user_extra" } @@ -708,7 +734,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_unsharded", "Inputs": [ @@ -720,6 +745,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" }, @@ -730,6 +756,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select (select :user_id + outm.m + unsharded.m from unsharded where 1 != 1) from unsharded as outm where 1 != 1", "Query": "select (select :user_id + outm.m + unsharded.m from unsharded) from unsharded as outm", "Table": "unsharded" } @@ -744,7 +771,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -756,6 +782,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.Col from user where 1 != 1", "Query": "select user.Col from user", "Table": "user" }, @@ -767,6 +794,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.Id from user_extra where 1 != 1", "Query": "select user_extra.Id from user_extra", "Table": "user_extra" } @@ -790,6 +818,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 0x04", "Table": "user" } @@ -802,9 +831,8 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(20)", - "Offset": "INT64(10)", + "Count": 20, + "Offset": 10, "Inputs": [ { "OperatorType": "Route", @@ -814,6 +842,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_id from music where 1 != 1", "Query": "select user_id from music order by user_id asc limit :__upper_limit", "Table": "music" } @@ -833,8 +862,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where name = 'abc' and id = 4 limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 4 + ], + "Vindex": "user_index" } } @@ -850,8 +884,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 4 and name = 'abc' limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 4 + ], + "Vindex": "user_index" } } @@ -867,8 +906,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 4 and name = 'abc' limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 4 + ], + "Vindex": "user_index" } } @@ -884,8 +928,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -901,8 +950,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -918,8 +972,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 1 and name = true limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -935,8 +994,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 1 and name limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -952,8 +1016,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 and name = true limit 5", - "Table": "user" + "Table": "user", + "Values": [ + 5 + ], + "Vindex": "user_index" } } @@ -964,7 +1033,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -974,6 +1042,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -984,6 +1053,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select a, :__sq1 from unsharded where 1 != 1", "Query": "select a, :__sq1 from unsharded", "Table": "unsharded" } @@ -998,7 +1068,6 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -1008,6 +1077,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, @@ -1018,6 +1088,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select a, 1 + :__sq1 from unsharded where 1 != 1", "Query": "select a, 1 + :__sq1 from unsharded", "Table": "unsharded" } @@ -1032,13 +1103,14 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "", - "TargetDestination": "VtGate()", - "Columns": "0, 1", + "Columns": [ + 0, + 1 + ], "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -1050,6 +1122,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user.id as id1 from user where 1 != 1", "Query": "select user.id as id1 from user", "Table": "user" }, @@ -1061,6 +1134,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select user_extra.id as id2 from user_extra where 1 != 1", "Query": "select user_extra.id as id2 from user_extra", "Table": "user_extra" } @@ -1089,8 +1163,8 @@ "Name": "main", "Sharded": false }, - "Query": "select * from information_schema.a union select * from information_schema.b", - "Table": "" + "FieldQuery": "select * from information_schema.a where 1 != 1 union select * from information_schema.b where 1 != 1", + "Query": "select * from information_schema.a union select * from information_schema.b" } } @@ -1106,8 +1180,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "music", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -1123,8 +1202,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "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" + "Table": "music", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -1138,6 +1222,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select * from (select col1, col2 from unsharded where 1 != 1 union select col1, col2 from unsharded where 1 != 1) as a where 1 != 1", "Query": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) as a", "Table": "unsharded" } @@ -1153,6 +1238,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select id, name from unsharded where 1 != 1", "Query": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "Table": "unsharded" } @@ -1168,6 +1254,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "(select id from unsharded where 1 != 1) union (select id from unsharded_auto where 1 != 1)", "Query": "(select id from unsharded) union (select id from unsharded_auto) order by id asc limit 5", "Table": "unsharded" } @@ -1183,6 +1270,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select id from unsharded where 1 != 1 union select id from unsharded_auto where 1 != 1 union select id from unsharded_auto where 1 != 1", "Query": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Table": "unsharded" } @@ -1198,6 +1286,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "(select id from unsharded where 1 != 1 union select id from unsharded_auto where 1 != 1) union (select id from unsharded_auto where 1 != 1 union select name from unsharded where 1 != 1)", "Query": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Table": "unsharded" } @@ -1213,6 +1302,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "(select id from unsharded where 1 != 1) union (select id from unsharded where 1 != 1)", "Query": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", "Table": "unsharded" } @@ -1230,8 +1320,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select a from user_metadata as route1 where 1 != 1 union select b from user_metadata as route1 where 1 != 1", "Query": "select a from user_metadata as route1 where email = 'aaa' union select b from user_metadata as route1 where email = 'aaa'", - "Table": "user_metadata" + "Table": "user_metadata", + "Values": [ + "aaa" + ], + "Vindex": "email_user_map" } } @@ -1246,6 +1341,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select * from unsharded as route2 where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from unsharded as route2", "Table": "unsharded" } diff --git a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt index 70bd38db048..d0434dabf51 100644 --- a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt @@ -7,7 +7,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_unsharded", "Inputs": [ @@ -19,6 +18,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select predef2 from user where 1 != 1", "Query": "select predef2 from user", "Table": "user" }, @@ -29,6 +29,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select predef3 from unsharded where 1 != 1", "Query": "select predef3 from unsharded where predef3 = :predef2", "Table": "unsharded" } diff --git a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt index 8afb86c3acc..35fe1ad903e 100644 --- a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt @@ -49,7 +49,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "_unsharded", "Inputs": [ @@ -64,6 +63,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded", "Table": "unsharded" } @@ -78,7 +78,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1,-1", "TableName": "unsharded_", "Inputs": [ @@ -89,6 +88,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded", "Table": "unsharded" }, @@ -107,7 +107,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2,1", "TableName": "_unsharded", "Inputs": [ @@ -122,6 +121,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", "Table": "unsharded" } @@ -136,7 +136,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "_unsharded", "Inputs": [ @@ -151,6 +150,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded where unsharded.id = :user_index_id", "Table": "unsharded" } @@ -165,7 +165,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "_unsharded", "Inputs": [ @@ -180,6 +179,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.id from unsharded where 1 != 1", "Query": "select unsharded.id from unsharded where unsharded.id = :ui_id", "Table": "unsharded" } @@ -201,7 +201,12 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from samecolvin where 1 != 1", "Query": "select col from samecolvin where col = :col", - "Table": "samecolvin" + "Table": "samecolvin", + "Values": [ + ":col" + ], + "Vindex": "vindex1" } } diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt index c1074daf549..ecf5cf8004e 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt @@ -5,7 +5,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1,-1,2", "TableName": "user_user_extra", "Inputs": [ @@ -17,6 +16,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id as uid from user as u where 1 != 1", "Query": "select u.id as uid from user as u", "Table": "user" }, @@ -28,6 +28,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid", "Table": "user_extra" } @@ -42,7 +43,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1,-1,2", "TableName": "user_user_extra", "Inputs": [ @@ -54,6 +54,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id as uid from user as u where 1 != 1", "Query": "select u.id as uid from user as u", "Table": "user" }, @@ -65,6 +66,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid1 and e.col = :uid", "Table": "user_extra" } @@ -79,14 +81,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_user", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user", "Inputs": [ @@ -98,6 +98,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" }, @@ -109,6 +110,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2", "Table": "user" } @@ -122,6 +124,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" } @@ -136,14 +139,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_user", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user", "Inputs": [ @@ -155,6 +156,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u1.id from user as u1 where 1 != 1", "Query": "select u1.id from user as u1", "Table": "user" }, @@ -166,6 +168,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u2.col from user as u2 where 1 != 1", "Query": "select u2.col from user as u2", "Table": "user" } @@ -179,6 +182,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u2_col", "Table": "user" } @@ -193,14 +197,12 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_user", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user", "Inputs": [ @@ -212,6 +214,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" }, @@ -223,6 +226,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2 where u2.col = :u1_col", "Table": "user" } @@ -236,6 +240,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" } @@ -253,21 +258,18 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_user_user", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user_user", "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,-2", "TableName": "user_user", "Inputs": [ @@ -279,6 +281,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" }, @@ -290,6 +293,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2", "Table": "user" } @@ -303,8 +307,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.id = :u1_col", - "Table": "user" + "Table": "user", + "Values": [ + ":u1_col" + ], + "Vindex": "user_index" } ] }, @@ -316,6 +325,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u4 where 1 != 1", "Query": "select 1 from user as u4 where u4.col = :u1_col", "Table": "user" } @@ -330,7 +340,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1", "TableName": "user_user_user", "Inputs": [ @@ -342,14 +351,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" }, { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", - "JoinColumnIndexes": "", "TableName": "user_user", "Inputs": [ { @@ -360,8 +368,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2 where u2.id = :u1_col", - "Table": "user" + "Table": "user", + "Values": [ + ":u1_col" + ], + "Vindex": "user_index" }, { "OperatorType": "Route", @@ -371,8 +384,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.id = :u1_col", - "Table": "user" + "Table": "user", + "Values": [ + ":u1_col" + ], + "Vindex": "user_index" } ] } @@ -387,7 +405,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "weird`name_unsharded", "Inputs": [ @@ -399,6 +416,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name` where 1 != 1", "Query": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name`", "Table": "weird`name" }, @@ -409,6 +427,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.b from unsharded where 1 != 1", "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", "Table": "unsharded" } @@ -423,7 +442,6 @@ "Instructions": { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "1", "TableName": "weird`name_unsharded", "Inputs": [ @@ -435,6 +453,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select `weird``name`.`a``b*c` from `weird``name` where 1 != 1", "Query": "select `weird``name`.`a``b*c` from `weird``name`", "Table": "weird`name" }, @@ -445,6 +464,7 @@ "Name": "main", "Sharded": false }, + "FieldQuery": "select unsharded.b from unsharded where 1 != 1", "Query": "select unsharded.b from unsharded where unsharded.id = :weird_name_a_b_c", "Table": "unsharded" } @@ -459,13 +479,11 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -477,6 +495,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u", "Table": "user" }, @@ -488,6 +507,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra" } @@ -504,18 +524,15 @@ "Instructions": { "OperatorType": "Subquery", "Variant": "PulloutIn", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1", "TableName": "user_user_extra", "Inputs": [ @@ -527,6 +544,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u", "Table": "user" }, @@ -538,6 +556,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra" } @@ -553,8 +572,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and id in ::__vals", - "Table": "user" + "Table": "user", + "Values": [ + "::__sq1" + ], + "Vindex": "user_index" } ] } @@ -567,13 +591,11 @@ "Instructions": { "OperatorType": "Limit", "Variant": "", - "TargetDestination": "VtGate()", - "Count": "INT64(10)", + "Count": 10, "Inputs": [ { "OperatorType": "Subquery", "Variant": "PulloutValue", - "TargetDestination": "VtGate()", "Inputs": [ { "OperatorType": "Route", @@ -583,13 +605,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" }, { "OperatorType": "Join", "Variant": "Join", - "TargetDestination": "VtGate()", "JoinColumnIndexes": "-1,1,-2", "TableName": "user_user_extra", "Inputs": [ @@ -601,6 +623,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select u.id, :__sq1, u.col from user as u where 1 != 1", "Query": "select u.id, :__sq1, u.col from user as u", "Table": "user" }, @@ -612,6 +635,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra" } From e6a864a11520f9259b8ad6a1879b18116448dac4 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 3 Apr 2020 09:32:00 +0200 Subject: [PATCH 09/10] Fixed unit tests Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/plan_description_test.go | 54 ++++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 61e0b6fed85..e114532c579 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -17,13 +17,12 @@ limitations under the License. package engine import ( - "encoding/json" - "fmt" "testing" + "vitess.io/vitess/go/test/utils" + "vitess.io/vitess/go/sqltypes" - "github.com/google/go-cmp/cmp" "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/vtgate/vindexes" @@ -41,22 +40,19 @@ func TestCreateRoutePlanDescription(t *testing.T) { TargetDestination: key.DestinationAllShards{}, TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]interface{}{ - "Query": route.Query, - "Table": route.TableName, + "Query": route.Query, + "Table": route.TableName, + "FieldQuery": route.FieldQuery, + "Vindex": route.Vindex.String(), }, Inputs: []PrimitiveDescription{}, } - if diff := cmp.Diff(planDescription, expected); diff != "" { - t.Errorf(diff) - bytes, _ := json.MarshalIndent(expected, "", " ") - fmt.Println(string(bytes)) - fmt.Printf("%v\n", expected) - } - + utils.MustMatch(t, expected, planDescription, "descriptions did not match") } func createRoute() *Route { + hash, _ := vindexes.NewHash("vindex name", nil) return &Route{ Opcode: SelectScatter, Keyspace: &vindexes.Keyspace{Name: "ks"}, @@ -65,7 +61,7 @@ func createRoute() *Route { Query: "select all the things", TableName: "tableName", FieldQuery: "more query", - Vindex: &vindexes.Null{}, + Vindex: hash.(*vindexes.Hash), Values: []sqltypes.PlanValue{}, OrderBy: []OrderbyParams{}, } @@ -74,9 +70,11 @@ func createRoute() *Route { func TestPlanDescriptionWithInputs(t *testing.T) { route := createRoute() routeDescr := getDescriptionFor(route) + count := int64PlanValue(12) + offset := int64PlanValue(4) limit := &Limit{ - Count: int64PlanValue(12), - Offset: int64PlanValue(4), + Count: count, + Offset: offset, Input: route, } @@ -85,22 +83,22 @@ func TestPlanDescriptionWithInputs(t *testing.T) { expected := PrimitiveDescription{ OperatorType: "Limit", Other: map[string]interface{}{ - "Count": "12", - "Offset": "4", + "Count": count.Value, + "Offset": offset.Value, }, Inputs: []PrimitiveDescription{routeDescr}, } - if diff := cmp.Diff(planDescription, expected); diff != "" { - t.Errorf(diff) - bytes, _ := json.MarshalIndent(expected, "", " ") - fmt.Println(string(bytes)) - bytes, _ = json.MarshalIndent(planDescription, "", " ") - fmt.Println(string(bytes)) - } - + mustMatch(t, expected, planDescription, "descriptions did not match") } +var mustMatch = utils.MustMatchFn( + []interface{}{ // types with unexported fields + sqltypes.Value{}, + }, + []string{}, // ignored fields +) + func getDescriptionFor(route *Route) PrimitiveDescription { return PrimitiveDescription{ OperatorType: "Route", @@ -109,8 +107,10 @@ func getDescriptionFor(route *Route) PrimitiveDescription { TargetDestination: key.DestinationAllShards{}, TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]interface{}{ - "Query": route.Query, - "TableName": route.TableName, + "Query": route.Query, + "Table": route.TableName, + "FieldQuery": route.FieldQuery, + "Vindex": route.Vindex.String(), }, Inputs: []PrimitiveDescription{}, } From 9089893f9ddd9bb64a59046a6cdddac1502017ab Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 3 Apr 2020 10:37:39 +0200 Subject: [PATCH 10/10] Query plan description clean up - Removed tablet type from route - Added vindex info to update/delete - Added NoAutoCommit to send Signed-off-by: Andres Taylor --- go/vt/vtgate/engine/delete.go | 27 +- go/vt/vtgate/engine/plan_description.go | 3 +- go/vt/vtgate/engine/plan_description_test.go | 4 - go/vt/vtgate/engine/route.go | 2 - go/vt/vtgate/engine/send.go | 5 +- go/vt/vtgate/engine/update.go | 62 +--- .../planbuilder/testdata/aggr_cases.txt | 44 --- .../planbuilder/testdata/bypass_cases.txt | 4 + .../vtgate/planbuilder/testdata/dml_cases.txt | 345 ++++++++++++------ .../planbuilder/testdata/filter_cases.txt | 58 --- .../planbuilder/testdata/from_cases.txt | 68 ---- .../testdata/memory_sort_cases.txt | 14 - .../testdata/postprocess_cases.txt | 51 --- .../planbuilder/testdata/select_cases.txt | 52 --- .../planbuilder/testdata/symtab_cases.txt | 1 - .../testdata/vindex_func_cases.txt | 1 - .../planbuilder/testdata/wireup_cases.txt | 30 -- 17 files changed, 280 insertions(+), 491 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index ef94fc43afa..64b5540d861 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -199,16 +199,15 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] func (del *Delete) description() PrimitiveDescription { other := map[string]interface{}{ - "Query": del.Query, - "TableName": del.GetTableName(), - } - if del.Vindex != nil { - other["Vindex"] = del.Vindex.String() - } - if del.KsidVindex != nil { - other["KsidVindexName"] = del.KsidVindex.String() + "Query": del.Query, + "Table": del.GetTableName(), + "OwnedVindexQuery": del.OwnedVindexQuery, + "MultiShardAutocommit": del.MultiShardAutocommit, + "QueryTimeout": del.QueryTimeout, } + addFieldsIfNotEmpty(del.DML, other) + return PrimitiveDescription{ OperatorType: "Delete", Keyspace: del.Keyspace, @@ -217,3 +216,15 @@ func (del *Delete) description() PrimitiveDescription { Other: other, } } + +func addFieldsIfNotEmpty(dml DML, other map[string]interface{}) { + if dml.Vindex != nil { + other["Vindex"] = dml.Vindex.String() + } + if dml.KsidVindex != nil { + other["KsidVindex"] = dml.KsidVindex.String() + } + if len(dml.Values) > 0 { + other["Values"] = dml.Values + } +} diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index 84c7bb4c788..3beb2cba2ac 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -27,6 +27,7 @@ import ( ) // PrimitiveDescription is used to create a serializable representation of the Primitive tree +// Using this structure, all primitives can share json marshalling code, which gives us an uniform output type PrimitiveDescription struct { OperatorType string Variant string @@ -91,7 +92,7 @@ func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) { func addMap(input map[string]interface{}, buf *bytes.Buffer) error { var mk []string for k, v := range input { - if v == "" || v == nil { + if v == "" || v == nil || v == 0 { continue } mk = append(mk, k) diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index e114532c579..9c47fed0d81 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -24,7 +24,6 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" - topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/vtgate/vindexes" ) @@ -38,7 +37,6 @@ func TestCreateRoutePlanDescription(t *testing.T) { Variant: "SelectScatter", Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, - TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]interface{}{ "Query": route.Query, "Table": route.TableName, @@ -57,7 +55,6 @@ func createRoute() *Route { Opcode: SelectScatter, Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, - TargetTabletType: topodatapb.TabletType_MASTER, Query: "select all the things", TableName: "tableName", FieldQuery: "more query", @@ -105,7 +102,6 @@ func getDescriptionFor(route *Route) PrimitiveDescription { Variant: routeName[route.Opcode], Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, - TargetTabletType: topodatapb.TabletType_MASTER, Other: map[string]interface{}{ "Query": route.Query, "Table": route.TableName, diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 8fc8c587dff..2d31da12c9b 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -568,7 +568,6 @@ func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) } func (route *Route) description() PrimitiveDescription { - other := map[string]interface{}{ "Query": route.Query, "Table": route.TableName, @@ -586,7 +585,6 @@ func (route *Route) description() PrimitiveDescription { Variant: routeName[route.Opcode], Keyspace: route.Keyspace, TargetDestination: route.TargetDestination, - TargetTabletType: route.TargetTabletType, Other: other, } } diff --git a/go/vt/vtgate/engine/send.go b/go/vt/vtgate/engine/send.go index e286ea241be..0c1c16e27c3 100644 --- a/go/vt/vtgate/engine/send.go +++ b/go/vt/vtgate/engine/send.go @@ -116,8 +116,9 @@ func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariabl func (s *Send) description() PrimitiveDescription { other := map[string]interface{}{ - "Query": s.Query, - "Table": s.GetTableName(), + "Query": s.Query, + "Table": s.GetTableName(), + "NoAutoCommit": s.NoAutoCommit, } return PrimitiveDescription{ OperatorType: "Send", diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index afcdebf158a..0737342fe66 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -23,7 +23,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" - "vitess.io/vitess/go/jsonutil" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/srvtopo" @@ -50,47 +49,6 @@ type Update struct { noInputs } -// MarshalJSON serializes the Update into a JSON representation. -// It's used for testing and diagnostics. -func (upd *Update) MarshalJSON() ([]byte, error) { - var tname, vindexName, ksidVindexName string - if upd.Table != nil { - tname = upd.Table.Name.String() - } - if upd.Vindex != nil { - vindexName = upd.Vindex.String() - } - if upd.KsidVindex != nil { - ksidVindexName = upd.KsidVindex.String() - } - marshalUpdate := struct { - Opcode string - Keyspace *vindexes.Keyspace `json:",omitempty"` - Query string `json:",omitempty"` - Vindex string `json:",omitempty"` - Values []sqltypes.PlanValue `json:",omitempty"` - ChangedVindexValues map[string]VindexValues `json:",omitempty"` - Table string `json:",omitempty"` - OwnedVindexQuery string `json:",omitempty"` - KsidVindex string `json:",omitempty"` - MultiShardAutocommit bool `json:",omitempty"` - QueryTimeout int `json:",omitempty"` - }{ - Opcode: upd.RouteType(), - Keyspace: upd.Keyspace, - Query: upd.Query, - Vindex: vindexName, - Values: upd.Values, - ChangedVindexValues: upd.ChangedVindexValues, - Table: tname, - OwnedVindexQuery: upd.OwnedVindexQuery, - KsidVindex: ksidVindexName, - MultiShardAutocommit: upd.MultiShardAutocommit, - QueryTimeout: upd.QueryTimeout, - } - return jsonutil.MarshalNoEscape(marshalUpdate) -} - var updName = map[DMLOpcode]string{ Unsharded: "UpdateUnsharded", Equal: "UpdateEqual", @@ -268,19 +226,25 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] } func (upd *Update) description() PrimitiveDescription { + other := map[string]interface{}{ + "Query": upd.Query, + "Table": upd.GetTableName(), + "OwnedVindexQuery": upd.OwnedVindexQuery, + "MultiShardAutocommit": upd.MultiShardAutocommit, + "QueryTimeout": upd.QueryTimeout, + } + + addFieldsIfNotEmpty(upd.DML, other) + var changedVindexes []string for vindex := range upd.ChangedVindexValues { changedVindexes = append(changedVindexes, vindex) } - sort.Strings(changedVindexes) - other := map[string]interface{}{ - "Query": upd.Query, - "Table": upd.GetTableName(), - } - + sort.Strings(changedVindexes) // We sort these so random changes in the map order does not affect output if len(changedVindexes) > 0 { - other["Vindex"] = changedVindexes + other["ChangedVindexValues"] = changedVindexes } + return PrimitiveDescription{ OperatorType: "Update", Keyspace: upd.Keyspace, diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt index 7ff0da298af..edaa16f9874 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt @@ -28,7 +28,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*), col from user where 1 != 1", "Query": "select count(*), col from user where id = 1", "Table": "user", @@ -50,7 +49,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select fun(1), col from user where 1 != 1", "Query": "select fun(1), col from user", "Table": "user" @@ -68,7 +66,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, id from user where 1 != 1", "Query": "select distinct col1, id from user", "Table": "user" @@ -86,7 +83,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, id from user where 1 != 1 group by col1", "Query": "select distinct col1, id from user group by col1", "Table": "user" @@ -111,7 +107,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*), a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", "Query": "select count(*), a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by a asc, textcol1 asc, b asc", "Table": "user" @@ -143,7 +138,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user where 1 != 1 group by a, textcol1, b", "Query": "select count(*) as k, a, textcol1, b, weight_string(textcol1) from user group by a, textcol1, b order by textcol1 asc, a asc, b asc", "Table": "user" @@ -171,7 +165,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select count(*) from user", "Table": "user" @@ -197,7 +190,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select sum(col) from user where 1 != 1", "Query": "select sum(col) from user", "Table": "user" @@ -223,7 +215,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select min(col) from user where 1 != 1", "Query": "select min(col) from user", "Table": "user" @@ -249,7 +240,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select max(col) from user where 1 != 1", "Query": "select max(col) from user", "Table": "user" @@ -275,7 +265,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1", "Query": "select distinct col1, col2 from user group by col1 order by col1 asc, col2 asc, col1 asc", "Table": "user" @@ -301,7 +290,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.a from user where 1 != 1", "Query": "select user.a from user", "Table": "user" @@ -332,7 +320,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id, count(*) from user where 1 != 1 group by id", "Query": "select id, count(*) from user group by id", "Table": "user" @@ -350,7 +337,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id, col, count(*) from user where 1 != 1 group by id, col", "Query": "select id, col, count(*) from user group by id, col", "Table": "user" @@ -375,7 +361,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", "Query": "select col, count(*) from user group by col order by col asc", "Table": "user" @@ -402,7 +387,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select name, count(*) from user where 1 != 1 group by name", "Query": "select name, count(*) from user group by name order by name asc", "Table": "user" @@ -422,7 +406,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id, 1 + count(*) from user where 1 != 1 group by id", "Query": "select id, 1 + count(*) from user group by id", "Table": "user" @@ -440,7 +423,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id as val, 1 + count(*) from user where 1 != 1 group by val", "Query": "select id as val, 1 + count(*) from user group by val", "Table": "user" @@ -458,7 +440,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select val as id, 1 + count(*) from user where 1 != 1 group by user.id", "Query": "select val as id, 1 + count(*) from user group by user.id", "Table": "user" @@ -476,7 +457,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select *, id, 1 + count(*) from user where 1 != 1 group by id", "Query": "select *, id, 1 + count(*) from user group by id", "Table": "user" @@ -494,7 +474,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -529,7 +508,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) as a from user where 1 != 1", "Query": "select count(*) as a from user", "Table": "user" @@ -557,7 +535,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id, count(*) from user where 1 != 1", "Query": "select id, count(*) from user", "Table": "user" @@ -583,7 +560,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select distinct col from user order by col asc", "Table": "user" @@ -609,7 +585,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1 group by col", "Query": "select col from user group by col order by col asc", "Table": "user" @@ -629,7 +604,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id, count(distinct col) from user where 1 != 1 group by id", "Query": "select id, count(distinct col) from user group by id", "Table": "user" @@ -654,7 +628,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col, count(distinct id) from user where 1 != 1 group by col", "Query": "select col, count(distinct id) from user group by col order by col asc", "Table": "user" @@ -681,7 +654,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" @@ -707,7 +679,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col2 from user where 1 != 1 group by col2", "Query": "select col2 from user group by col2 order by col2 asc", "Table": "user" @@ -734,7 +705,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" @@ -761,7 +731,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" @@ -788,7 +757,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, min(distinct col2) from user where 1 != 1 group by col1", "Query": "select col1, min(distinct col2) from user group by col1 order by col1 asc", "Table": "user" @@ -820,7 +788,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1, col2 from user where 1 != 1 group by col1, col2", "Query": "select col1, col2 from user group by col1, col2 order by col1 asc, col2 asc", "Table": "user" @@ -853,7 +820,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by b, a", "Query": "select a, b, count(*) from user group by b, a order by b asc, a asc", "Table": "user" @@ -880,7 +846,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by 2, 1", "Query": "select a, b, count(*) from user group by 2, 1 order by b asc, a asc", "Table": "user" @@ -906,7 +871,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1 group by 1", "Query": "select col from user group by 1 order by col asc", "Table": "user" @@ -936,7 +900,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select count(*) from user", "Table": "user" @@ -967,7 +930,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1 asc, 2 asc, 3 asc", "Table": "user" @@ -994,7 +956,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a asc, b asc, c asc", "Table": "user" @@ -1021,7 +982,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 1, 2, 3, 4", "Query": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d asc, b asc, a asc, c asc", "Table": "user" @@ -1048,7 +1008,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, c, d, count(*) from user where 1 != 1 group by 3, 2, 1, 4", "Query": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d asc, b asc, a asc, c asc", "Table": "user" @@ -1075,7 +1034,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, c, count(*) from user where 1 != 1 group by 3, 2, 1", "Query": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b asc", "Table": "user" @@ -1111,7 +1069,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col, count(*) from user where 1 != 1 group by col", "Query": "select col, count(*) from user group by col order by col asc limit :__upper_limit", "Table": "user" @@ -1133,7 +1090,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt index be39902e355..1694d3f77e5 100644 --- a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt @@ -10,6 +10,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", + "NoAutoCommit": true, "Query": "select count(*), col from unsharded" } } @@ -26,6 +27,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", + "NoAutoCommit": false, "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1" } } @@ -42,6 +44,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", + "NoAutoCommit": false, "Query": "delete from USER where ID = 42" } } @@ -58,6 +61,7 @@ "Sharded": false }, "TargetDestination": "Shard(-80)", + "NoAutoCommit": false, "Query": "insert into USER(ID, NAME) values (42, 'ms X')" } } diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt index 793a0cc99be..245d6d4efd6 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt @@ -18,6 +18,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update m1 set val = 1" } } @@ -34,6 +35,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded set val = 1" } } @@ -50,6 +52,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded set col = (select col from unsharded limit 1)" } } @@ -66,6 +69,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded set col = (select id from unsharded union select id from unsharded)" } } @@ -82,6 +86,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded set col = (select id from unsharded as a join unsharded as b on a.id = b.id)" } } @@ -98,6 +103,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col \u003c 1000" } } @@ -114,8 +120,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user as route1 set a = 1 where id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -131,6 +142,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded_a set a = (select a from unsharded as route2)" } } @@ -147,6 +159,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from unsharded" } } @@ -163,8 +176,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1 where id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -180,8 +198,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user as user_alias set val = 1 where user_alias.id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -197,8 +220,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1 where id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -214,8 +242,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1 where name = 'foo' and id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -231,11 +264,18 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "ChangedVindexValues": [ + "email_user_map" + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 for update", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", "Table": "user_metadata", - "Vindex": [ - "email_user_map" - ] + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -255,12 +295,19 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "Query": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", - "Table": "user_metadata", - "Vindex": [ + "ChangedVindexValues": [ "address_user_map", "email_user_map" - ] + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 for update", + "Query": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", + "Table": "user_metadata", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -276,11 +323,18 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "ChangedVindexValues": [ + "email_user_map" + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select user_id, email, address from user_metadata where user_id = 1 order by user_id asc limit 10 for update", "Query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", "Table": "user_metadata", - "Vindex": [ - "email_user_map" - ] + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -296,8 +350,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1 where id = id2 and id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -313,8 +372,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1 where id = 18446744073709551616 and id = 1", - "Table": "user" + "Table": "user", + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -330,9 +394,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", "Query": "delete from user where id = 1", - "TableName": "user", + "Table": "user", + "Values": [ + 1 + ], "Vindex": "user_index" } } @@ -349,6 +418,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete a from unsharded_a as a, unsharded_b as b where a.id = b.id and b.val = 1" } } @@ -365,6 +435,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete a from unsharded_a as a join unsharded_b as b on a.id = b.id where b.val = 1" } } @@ -381,6 +452,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col \u003c 1000" } } @@ -397,9 +469,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", "Query": "delete from user as route1 where id = 1", - "TableName": "user", + "Table": "user", + "Values": [ + 1 + ], "Vindex": "user_index" } } @@ -416,6 +493,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from unsharded_a where a = (select a from unsharded as route2)" } } @@ -432,8 +510,13 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update music set val = 1 where id = 1", - "Table": "music" + "Table": "music", + "Values": [ + 1 + ], + "Vindex": "music_user_map" } } @@ -449,6 +532,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded_a as a join unsharded_b as b on a.id = b.id set a.val = 'foo' where b.val = 1" } } @@ -465,6 +549,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded_a as a, unsharded_b as b set a.val = 'foo' where a.id = b.id and b.val = 1" } } @@ -481,9 +566,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select user_id, id from music where id = 1 for update", "Query": "delete from music where id = 1", - "TableName": "music", + "Table": "music", + "Values": [ + 1 + ], "Vindex": "music_user_map" } } @@ -500,8 +590,12 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from music_extra where user_id = 1", - "TableName": "music_extra", + "Table": "music_extra", + "Values": [ + 1 + ], "Vindex": "user_index" } } @@ -520,7 +614,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded values ()", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -539,7 +632,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded values (1, 2)", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -558,7 +650,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded values (1, 2) on duplicate key update x = 3", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -577,7 +668,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded_authoritative(col1, col2) values (:__seq0, 1)", - "QueryTimeout": 0, "TableName": "unsharded_authoritative" } } @@ -596,7 +686,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into music(user_id, id) values (:_user_id0, :_id0) on duplicate key update user_id = values(user_id)", - "QueryTimeout": 0, "TableName": "music" } } @@ -615,7 +704,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into music(user_id, id) values (:_user_id0, :_id0), (:_user_id1, :_id1) on duplicate key update user_id = values(user_id)", - "QueryTimeout": 0, "TableName": "music" } } @@ -634,7 +722,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded select id from unsharded_auto", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -653,7 +740,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded select id from unsharded join unsharded_auto", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -676,7 +762,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa')", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -695,7 +780,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(val, id) values ('aa', :__seq0)", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -714,7 +798,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(val, id) values (false, :__seq0)", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -733,7 +816,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -752,7 +834,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded values ((select 1 from dual), 1)", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -771,7 +852,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -794,7 +874,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into authoritative(user_id, col1, col2) values (:_user_id0, 2, 3)", - "QueryTimeout": 0, "TableName": "authoritative" } } @@ -817,7 +896,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -836,7 +914,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert ignore into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -855,7 +932,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0) on duplicate key update col = 2", - "QueryTimeout": 0, "TableName": "user" } } @@ -874,7 +950,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -893,7 +968,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(nonid, id, Name, Costly) values (2, :_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -912,7 +986,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, nonid, Name, Costly) values (:_Id0, 2, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -931,7 +1004,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(nonid, id, Name, Costly) values (true, :_Id0, :_Name0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -950,7 +1022,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(nonid, name, id, Costly) values (2, :_Name0, :_Id0, :_Costly0)", - "QueryTimeout": 0, "TableName": "user" } } @@ -969,7 +1040,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user_extra(nonid, extra_id, user_id) values (2, :__seq0, :_user_id0)", - "QueryTimeout": 0, "TableName": "user_extra" } } @@ -988,7 +1058,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into `weird``name`(`a``b*c`, `b*c`) values (:_a_b_c0, 2)", - "QueryTimeout": 0, "TableName": "weird`name" } } @@ -1007,7 +1076,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded select 1 from dual union select 1 from dual", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1042,7 +1110,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "QueryTimeout": 0, "TableName": "user" } } @@ -1080,7 +1147,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": true, "Query": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)", - "QueryTimeout": 0, "TableName": "user" } } @@ -1103,7 +1169,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "replace into unsharded values (1, 2)", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1122,7 +1187,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "replace into unsharded select id from unsharded_auto", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1145,7 +1209,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa')", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1164,7 +1227,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(val, id) values ('aa', :__seq0)", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1183,7 +1245,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "replace into unsharded_auto(id, val) values (:__seq0, 'aa'), (:__seq1, 'bb')", - "QueryTimeout": 0, "TableName": "unsharded_auto" } } @@ -1206,7 +1267,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0)", - "QueryTimeout": 0, "TableName": "multicolvin" } } @@ -1225,7 +1285,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into overlap_vindex(kid, column_a, column_b) values (:_kid0, :_column_a0, 3)", - "QueryTimeout": 0, "TableName": "overlap_vindex" } } @@ -1244,7 +1303,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into multicolvin(column_a, column_b, column_c, kid) values (:_column_a0, :_column_b0, :_column_c0, :_kid0), (:_column_a1, :_column_b1, :_column_c1, :_kid1)", - "QueryTimeout": 0, "TableName": "multicolvin" } } @@ -1261,9 +1319,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "kid_index", + "KsidVindex": "kid_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", "Query": "delete from multicolvin where kid = 1", - "TableName": "multicolvin", + "Table": "multicolvin", + "Values": [ + 1 + ], "Vindex": "kid_index" } } @@ -1280,11 +1343,18 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "ChangedVindexValues": [ + "colb_colc_map" + ], + "KsidVindex": "kid_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", "Query": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", "Table": "multicolvin", - "Vindex": [ - "colb_colc_map" - ] + "Values": [ + 1 + ], + "Vindex": "kid_index" } } @@ -1300,12 +1370,19 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "Query": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", - "Table": "multicolvin", - "Vindex": [ + "ChangedVindexValues": [ "cola_map", "colb_colc_map" - ] + ], + "KsidVindex": "kid_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", + "Query": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", + "Table": "multicolvin", + "Values": [ + 1 + ], + "Vindex": "kid_index" } } @@ -1321,6 +1398,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1", "Table": "user_extra" } @@ -1338,6 +1416,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1", "Table": "user_extra" } @@ -1355,6 +1434,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": true, "Query": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", "Table": "user_extra" } @@ -1372,7 +1452,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", + "QueryTimeout": 1, "Table": "user_extra" } } @@ -1389,6 +1471,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1 where id between 1 and 2", "Table": "user_extra" } @@ -1406,6 +1489,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1 where user_id in (1, 2)", "Table": "user_extra" } @@ -1423,6 +1507,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1 where name = 'foo'", "Table": "user_extra" } @@ -1440,6 +1525,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1 where id in (1, 2)", "Table": "user_extra" } @@ -1457,6 +1543,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user_extra set val = 1 where name = 'foo' or id = 1", "Table": "user_extra" } @@ -1474,8 +1561,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from user_extra", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1491,8 +1579,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from user_extra", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1508,8 +1597,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from user_extra where user_id between 1 and 2", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1525,8 +1615,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from user_extra where name = 'jose'", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1542,8 +1633,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": true, "Query": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1559,8 +1651,10 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete /*vt+ QUERY_TIMEOUT_MS=1 */ from user_extra where name = 'jose'", - "TableName": "user_extra" + "QueryTimeout": 1, + "Table": "user_extra" } } @@ -1576,8 +1670,9 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from user_extra where user_id in (1, 2)", - "TableName": "user_extra" + "Table": "user_extra" } } @@ -1593,6 +1688,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)" } } @@ -1609,6 +1705,7 @@ "Sharded": false }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)" } } @@ -1625,11 +1722,18 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "ChangedVindexValues": [ + "name_user_map" + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id = 1 for update", "Query": "update user set name = null where id = 1", "Table": "user", - "Vindex": [ - "name_user_map" - ] + "Values": [ + 1 + ], + "Vindex": "user_index" } } @@ -1647,7 +1751,6 @@ "TargetTabletType": "MASTER", "MultiShardAutocommit": false, "Query": "insert into unsharded values (:__lastInsertId, 2)", - "QueryTimeout": 0, "TableName": "unsharded" } } @@ -1664,11 +1767,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "Query": "update user set name = null where id in (1, 2, 3)", - "Table": "user", - "Vindex": [ + "ChangedVindexValues": [ "name_user_map" - ] + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id in (1, 2, 3) for update", + "Query": "update user set name = null where id in (1, 2, 3)", + "Table": "user" } } @@ -1684,11 +1790,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "Query": "update user set name = null", - "Table": "user", - "Vindex": [ + "ChangedVindexValues": [ "name_user_map" - ] + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user for update", + "Query": "update user set name = null", + "Table": "user" } } @@ -1704,11 +1813,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "Query": "update user set name = null where id + 1 = 2", - "Table": "user", - "Vindex": [ + "ChangedVindexValues": [ "name_user_map" - ] + ], + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id + 1 = 2 for update", + "Query": "update user set name = null where id + 1 = 2", + "Table": "user" } } @@ -1724,9 +1836,11 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id in (1, 2, 3) for update", "Query": "delete from user where id in (1, 2, 3)", - "TableName": "user" + "Table": "user" } } @@ -1742,9 +1856,11 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user where id + 1 = 2 for update", "Query": "delete from user where id + 1 = 2", - "TableName": "user" + "Table": "user" } } @@ -1760,9 +1876,11 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user for update", "Query": "delete from user", - "TableName": "user" + "Table": "user" } } @@ -1778,9 +1896,14 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select user_id, id from music where id = 1 for update", "Query": "delete music from music where id = 1", - "TableName": "music", + "Table": "music", + "Values": [ + 1 + ], "Vindex": "music_user_map" } } @@ -1797,6 +1920,7 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "MultiShardAutocommit": false, "Query": "update user set val = 1", "Table": "user" } @@ -1814,9 +1938,11 @@ "Sharded": true }, "TargetTabletType": "MASTER", - "KsidVindexName": "user_index", + "KsidVindex": "user_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select Id, Name, Costly from user for update", "Query": "delete from user", - "TableName": "user" + "Table": "user" } } @@ -1832,10 +1958,17 @@ "Sharded": true }, "TargetTabletType": "MASTER", + "ChangedVindexValues": [ + "colb_colc_map" + ], + "KsidVindex": "kid_index", + "MultiShardAutocommit": false, + "OwnedVindexQuery": "select kid, column_a, column_b, column_c from multicolvin where kid = 1 for update", "Query": "update multicolvin set column_c = 2 where kid = 1", "Table": "multicolvin", - "Vindex": [ - "colb_colc_map" - ] + "Values": [ + 1 + ], + "Vindex": "kid_index" } } diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt index bdfac478e36..c2782fe009e 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt @@ -9,7 +9,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user", "Table": "user" @@ -27,7 +26,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 5", "Table": "user", @@ -49,7 +47,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 5 + 5", "Table": "user" @@ -67,7 +64,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from music where 1 != 1", "Query": "select id from music where id = 5 and user_id = 4", "Table": "music", @@ -89,7 +85,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where costly = 'aa' and name = 'bb'", "Table": "user", @@ -111,7 +106,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where costly in ('aa', 'bb') and name in ::__vals", "Table": "user", @@ -136,7 +130,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name in (col, 'bb')", "Table": "user" @@ -154,7 +147,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name = :a", "Table": "user", @@ -176,7 +168,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name = 18446744073709551615", "Table": "user", @@ -198,7 +189,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where name in ::__vals", "Table": "user", @@ -220,7 +210,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -242,7 +231,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -264,7 +252,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -286,7 +273,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -314,7 +300,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", "Table": "user", @@ -330,7 +315,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", "Table": "user_extra" @@ -356,7 +340,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", "Table": "user", @@ -372,7 +355,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -402,7 +384,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -414,7 +395,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -444,7 +424,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where 1 = 1", "Table": "user" @@ -456,7 +435,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", "Table": "user_extra" @@ -476,7 +454,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.col = 5 and user.id in ::__vals", "Table": "user", @@ -501,7 +478,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -526,7 +502,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -548,7 +523,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -570,7 +544,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -592,7 +565,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -614,7 +586,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "Table": "user" @@ -638,7 +609,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" @@ -669,7 +639,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user as route1 where 1 != 1", "Query": "select col from user as route1 where id = 1", "Table": "user", @@ -691,7 +660,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user_metadata as route1 where 1 != 1", "Query": "select col from user_metadata as route1 where email = 'aaa'", "Table": "user_metadata", @@ -735,7 +703,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra", "Table": "user_extra" @@ -747,7 +714,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.m from user as u where 1 != 1", "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", @@ -780,7 +746,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -792,7 +757,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -822,7 +786,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.col from user_extra", "Table": "user_extra" @@ -834,7 +797,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.m from user as u where 1 != 1", "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", @@ -861,7 +823,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "Table": "user" @@ -879,7 +840,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -901,7 +861,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -923,7 +882,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -949,7 +907,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id2 from user as uu where 1 != 1", "Query": "select id2 from user as uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "Table": "user" @@ -972,7 +929,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -984,7 +940,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1 = 1 and id in ::__vals", "Table": "user", @@ -1012,7 +967,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1024,7 +978,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1 = 0 or id not in ::__sq1", "Table": "user" @@ -1048,7 +1001,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1060,7 +1012,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where :__sq_has_values1", "Table": "user" @@ -1084,7 +1035,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1096,7 +1046,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where id = :__sq1", "Table": "user", @@ -1128,7 +1077,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id3 from user where 1 != 1", "Query": "select id3 from user", "Table": "user" @@ -1140,7 +1088,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id2 from user where 1 != 1", "Query": "select id2 from user where :__sq_has_values1 = 1 and id2 in ::__sq1", "Table": "user" @@ -1154,7 +1101,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id1 from user where 1 != 1", "Query": "select id1 from user where id = :__sq2", "Table": "user", @@ -1178,7 +1124,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = (select id from user as route2 where route2.id = user.id)", "Table": "user" @@ -1211,7 +1156,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = :__sq1", "Table": "user", @@ -1235,7 +1179,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1257,7 +1200,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user where database()", "Table": "user" diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index 72f779b5b70..60a4c1af0c5 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -9,7 +9,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -117,7 +116,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" @@ -129,7 +127,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col from music where 1 != 1", "Query": "select music.col from music", "Table": "music" @@ -149,7 +146,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user", "Table": "user" @@ -167,7 +163,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user as a where 1 != 1", "Query": "select * from user as a", "Table": "user" @@ -185,7 +180,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user as route1 where 1 != 1", "Query": "select * from user as route1", "Table": "user" @@ -203,7 +197,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user as a where 1 != 1", "Query": "select * from user as a", "Table": "user" @@ -221,7 +214,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user as master_redirect where 1 != 1", "Query": "select * from user as master_redirect", "Table": "user" @@ -253,7 +245,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" @@ -265,7 +256,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col from music where 1 != 1", "Query": "select music.col from music", "Table": "music" @@ -358,7 +348,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.col, u.a from user as u where 1 != 1", "Query": "select u.col, u.a from user as u", "Table": "user" @@ -401,7 +390,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -451,7 +439,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -468,7 +455,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.col from user_extra as e where 1 != 1", "Query": "select e.col from user_extra as e where e.col = :user_col", "Table": "user_extra" @@ -564,7 +550,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -614,7 +599,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -651,7 +635,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -668,7 +651,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u1 where 1 != 1", "Query": "select 1 from user as u1", "Table": "user" @@ -701,7 +683,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user use index (a) where 1 != 1", "Query": "select user.col from user use index (a)", "Table": "user" @@ -719,7 +700,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", "Table": "user" @@ -737,7 +717,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.id = user_extra.user_id", "Table": "user" @@ -755,7 +734,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id where 1 != 1", "Query": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Table": "user" @@ -773,7 +751,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join user_extra on user_extra.user_id = user.id where 1 != 1", "Query": "select user.col from user join user_extra on user_extra.user_id = user.id", "Table": "user" @@ -791,7 +768,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -819,7 +795,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col, user.id from user where 1 != 1", "Query": "select user.col, user.id from user", "Table": "user" @@ -831,7 +806,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where :user_id \u003c user_extra.user_id", "Table": "user_extra" @@ -857,7 +831,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", "Table": "user", @@ -873,7 +846,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -899,7 +871,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.id = 5", "Table": "user", @@ -915,7 +886,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -941,7 +911,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col, user.id from user where 1 != 1", "Query": "select user.col, user.id from user", "Table": "user" @@ -953,7 +922,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :user_id", "Table": "user_extra" @@ -979,7 +947,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.user_id from user_extra where 1 != 1", "Query": "select user_extra.user_id from user_extra", "Table": "user_extra" @@ -991,7 +958,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user where user.name = :user_extra_user_id", "Table": "user", @@ -1015,7 +981,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join ref where 1 != 1", "Query": "select user.col from user join ref", "Table": "user" @@ -1050,7 +1015,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select ref.col from ref join user where 1 != 1", "Query": "select ref.col from ref join user", "Table": "user" @@ -1068,7 +1032,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id where 1 != 1", "Query": "select route2.col from user as route2 join user_extra on route2.id = user_extra.user_id", "Table": "user" @@ -1103,7 +1066,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -1123,7 +1085,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1145,7 +1106,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1167,7 +1127,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1193,7 +1152,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select t.id from user_extra join (select id from user where 1 != 1) as t on t.id = user_extra.user_id where 1 != 1", "Query": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Table": "user_extra" @@ -1217,7 +1175,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1233,7 +1190,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :t_id", "Table": "user_extra" @@ -1253,7 +1209,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1275,7 +1230,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from (select id, col from user_metadata as route1 where 1 != 1) as t where 1 != 1", "Query": "select id from (select id, col from user_metadata as route1 where email = 'aaa') as t", "Table": "user_metadata", @@ -1297,7 +1251,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1319,7 +1272,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1463,7 +1415,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id, user.col1 from user where 1 != 1", "Query": "select user.id, user.col1 from user", "Table": "user" @@ -1475,7 +1426,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -1523,7 +1473,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id, user.col1, user.col from user where 1 != 1", "Query": "select user.id, user.col1, user.col from user", "Table": "user" @@ -1535,7 +1484,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra where user_extra.col = :user_col", "Table": "user_extra" @@ -1587,7 +1535,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id, user.col1 from user where 1 != 1", "Query": "select user.id, user.col1 from user", "Table": "user" @@ -1599,7 +1546,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -1627,7 +1573,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1662,7 +1607,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1697,7 +1641,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1732,7 +1675,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1761,7 +1703,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" @@ -1805,7 +1746,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1817,7 +1757,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" @@ -1850,7 +1789,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1879,7 +1817,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and user.col in ::__sq1", "Table": "user" @@ -1920,7 +1857,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col1, user.col2 from user where 1 != 1", "Query": "select user.col1, user.col2 from user", "Table": "user" @@ -1968,7 +1904,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user join user_extra on user.ID = user_extra.User_Id where 1 != 1", "Query": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Table": "user" @@ -2000,7 +1935,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" @@ -2012,7 +1946,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -2069,7 +2002,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select :__lastInsertId as `last_insert_id()` from user where 1 != 1", "Query": "select :__lastInsertId as `last_insert_id()` from user", "Table": "user" diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt index 3988de493be..8a9688faaff 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt @@ -22,7 +22,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) from user where 1 != 1 group by a", "Query": "select a, b, count(*) from user group by a order by a asc", "Table": "user" @@ -56,7 +55,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" @@ -90,7 +88,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" @@ -129,7 +126,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by a asc", "Table": "user" @@ -165,7 +161,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, b, count(*) as k from user where 1 != 1 group by a", "Query": "select a, b, count(*) as k from user group by a order by 1 asc", "Table": "user" @@ -200,7 +195,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select textcol1, count(*) as k, weight_string(textcol1) from user where 1 != 1 group by textcol1", "Query": "select textcol1, count(*) as k, weight_string(textcol1) from user group by textcol1 order by textcol1 asc, textcol1 asc", "Table": "user" @@ -240,7 +234,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id, user.col from user where 1 != 1", "Query": "select user.id, user.col from user", "Table": "user" @@ -252,7 +245,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -287,7 +279,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -303,7 +294,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col3 as c from music where 1 != 1", "Query": "select music.col3 as c from music where music.id = :user_id", "Table": "music", @@ -340,7 +330,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", "Table": "user", @@ -356,7 +345,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", @@ -393,7 +381,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", "Table": "user" @@ -448,7 +435,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u where 1 != 1", "Query": "select u.a, u.textcol1, weight_string(u.textcol1) from user as u", "Table": "user" diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt index 62b4ae349e6..d17e6c25a23 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt @@ -9,7 +9,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col1 from user where 1 != 1", "Query": "select user.col1 from user having col2 = 2", "Table": "user" @@ -37,7 +36,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col1 from user where 1 != 1", "Query": "select user.col1 from user", "Table": "user" @@ -49,7 +47,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.col1 from user_extra where 1 != 1", "Query": "select user_extra.col1 from user_extra having user_extra.col1 = 2", "Table": "user_extra" @@ -75,7 +72,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col1 as a, user.col2 from user where 1 != 1", "Query": "select user.col1 as a, user.col2 from user having 1 = 1 and a = 1 and a = user.col2", "Table": "user" @@ -87,7 +83,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.col3 from user_extra where 1 != 1", "Query": "select user_extra.col3 from user_extra having user_extra.col3 = 1", "Table": "user_extra" @@ -111,7 +106,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -123,7 +117,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user having :__sq_has_values1 = 1 and id in ::__vals", "Table": "user", @@ -147,7 +140,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = 5 order by aa asc", "Table": "user", @@ -169,7 +161,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where id = 1 order by 1 asc", "Table": "user", @@ -191,7 +182,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by col asc", "Table": "user" @@ -209,7 +199,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", "Query": "select user_id, col1, col2 from authoritative order by user_id asc", "Table": "authoritative" @@ -227,7 +216,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_id, col1, col2, weight_string(col1) from authoritative where 1 != 1", "Query": "select user_id, col1, col2, weight_string(col1) from authoritative order by col1 asc", "Table": "authoritative" @@ -245,7 +233,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, textcol1, b, weight_string(textcol1) from user where 1 != 1", "Query": "select a, textcol1, b, weight_string(textcol1) from user order by a asc, textcol1 asc, b asc", "Table": "user" @@ -263,7 +250,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, user.textcol1, b, weight_string(user.textcol1) from user where 1 != 1", "Query": "select a, user.textcol1, b, weight_string(user.textcol1) from user order by a asc, textcol1 asc, b asc", "Table": "user" @@ -281,7 +267,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user where 1 != 1", "Query": "select a, textcol1, b, textcol2, weight_string(textcol1), weight_string(textcol2) from user order by a asc, textcol1 asc, b asc, textcol2 asc", "Table": "user" @@ -303,7 +288,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by null", "Table": "user" @@ -325,7 +309,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" @@ -337,7 +320,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by col asc", "Table": "user" @@ -363,7 +345,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -379,7 +360,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -409,7 +389,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -425,7 +404,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", @@ -455,7 +433,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -471,7 +448,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select music.col3 from music where 1 != 1", "Query": "select music.col3 from music where music.id = :user_id", "Table": "music", @@ -499,7 +475,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" @@ -511,7 +486,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by null", "Table": "user" @@ -531,7 +505,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user order by RAND()", "Table": "user" @@ -555,7 +528,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -571,7 +543,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -599,7 +570,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col2 from user where 1 != 1", "Query": "select col2 from user", "Table": "user" @@ -611,7 +581,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 order by rand()", "Table": "user" @@ -631,7 +600,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by col asc", "Table": "user", @@ -653,7 +621,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user where id = 5 order by user.col asc", "Table": "user", @@ -675,7 +642,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by user.col asc", "Table": "user", @@ -703,7 +669,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u where u.col in (select * from user where user.id = u.id order by col asc)", "Table": "user" @@ -715,7 +680,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.col = :u_col", "Table": "user_extra" @@ -751,7 +715,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -773,7 +736,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 order by -col1 asc", "Table": "user", @@ -795,7 +757,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -817,7 +778,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -839,7 +799,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -861,7 +820,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -883,7 +841,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user_metadata as route1 where 1 != 1", "Query": "select col from user_metadata as route1 where email = 'aaa' order by col asc", "Table": "user_metadata", @@ -905,7 +862,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1 from user where 1 != 1", "Query": "select col1 from user where id = 1 limit 1", "Table": "user", @@ -939,7 +895,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -951,7 +906,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra", "Table": "user_extra" @@ -978,7 +932,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user limit :__upper_limit", "Table": "user" @@ -1003,7 +956,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user limit :__upper_limit", "Table": "user" @@ -1028,7 +980,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id1 = 4 and name1 = 'abc' limit :__upper_limit", "Table": "user" @@ -1057,7 +1008,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col1 from user where 1 != 1", "Query": "select col1 from user", "Table": "user" @@ -1069,7 +1019,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user where :__sq_has_values1 = 1 and col in ::__sq1 limit :__upper_limit", "Table": "user" diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index de20905435c..4e405f99189 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -9,7 +9,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" @@ -27,7 +26,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" @@ -45,7 +43,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user", "Table": "user" @@ -63,7 +60,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "Table": "user" @@ -87,7 +83,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", "Table": "user" @@ -112,7 +107,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit :__upper_limit", "Table": "user" @@ -132,7 +126,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user", "Table": "user" @@ -156,7 +149,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Table": "user" @@ -182,7 +174,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select count(*) from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Table": "user" @@ -207,7 +198,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit :__upper_limit", "Table": "user" @@ -227,7 +217,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" @@ -245,7 +234,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.* from user where 1 != 1", "Query": "select user.* from user", "Table": "user" @@ -263,7 +251,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_id, col1, col2 from authoritative where 1 != 1", "Query": "select user_id, col1, col2 from authoritative", "Table": "authoritative" @@ -281,7 +268,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id where 1 != 1", "Query": "select a.user_id as user_id, a.col1 as col1, a.col2 as col2, b.user_id as user_id, b.col1 as col1, b.col2 as col2 from authoritative as a join authoritative as b on a.user_id = b.user_id", "Table": "authoritative" @@ -303,7 +289,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a.user_id, a.col1, a.col2 from authoritative as a where 1 != 1", "Query": "select a.user_id, a.col1, a.col2 from authoritative as a", "Table": "authoritative" @@ -321,7 +306,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from authoritative join user on authoritative.user_id = user.id where 1 != 1", "Query": "select * from authoritative join user on authoritative.user_id = user.id", "Table": "authoritative" @@ -339,7 +323,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id where 1 != 1", "Query": "select user.id, a.user_id, a.col1, a.col2, user.col1 from authoritative as a join user on a.user_id = user.id", "Table": "authoritative" @@ -357,7 +340,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user join user_extra on user.id = user_extra.user_id where 1 != 1", "Query": "select col from user join user_extra on user.id = user_extra.user_id", "Table": "user" @@ -385,7 +367,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select id from user where 1 != 1", "Query": "select id from user", "Table": "user" @@ -397,7 +378,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_id from user_extra where 1 != 1", "Query": "select user_id from user_extra", "Table": "user_extra" @@ -516,7 +496,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user", "Table": "user" @@ -528,7 +507,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" @@ -554,7 +532,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -566,7 +543,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" @@ -592,7 +568,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user", "Table": "user" @@ -604,7 +579,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.id + user_extra.col from user_extra where 1 != 1", "Query": "select user_extra.id + user_extra.col from user_extra", "Table": "user_extra" @@ -630,7 +604,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col, user.col2 from user where 1 != 1", "Query": "select user.col, user.col2 from user", "Table": "user" @@ -642,7 +615,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.id from user_extra where 1 != 1", "Query": "select user_extra.id from user_extra", "Table": "user_extra" @@ -668,7 +640,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select /* comment */ user.col from user", "Table": "user" @@ -680,7 +651,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select /* comment */ 1 from user_extra", "Table": "user_extra" @@ -706,7 +676,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.col from user where 1 != 1", "Query": "select user.col from user for update", "Table": "user" @@ -718,7 +687,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user_extra where 1 != 1", "Query": "select 1 from user_extra for update", "Table": "user_extra" @@ -744,7 +712,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id from user where 1 != 1", "Query": "select user.id from user", "Table": "user" @@ -781,7 +748,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.Col from user where 1 != 1", "Query": "select user.Col from user", "Table": "user" @@ -793,7 +759,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.Id from user_extra where 1 != 1", "Query": "select user_extra.Id from user_extra", "Table": "user_extra" @@ -817,7 +782,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 0x04", "Table": "user" @@ -841,7 +805,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_id from music where 1 != 1", "Query": "select user_id from music order by user_id asc limit :__upper_limit", "Table": "music" @@ -861,7 +824,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where name = 'abc' and id = 4 limit 5", "Table": "user", @@ -883,7 +845,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 4 and name = 'abc' limit 5", "Table": "user", @@ -905,7 +866,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 4 and name = 'abc' limit 5", "Table": "user", @@ -927,7 +887,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -949,7 +908,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -971,7 +929,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 1 and name = true limit 5", "Table": "user", @@ -993,7 +950,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 1 and name limit 5", "Table": "user", @@ -1015,7 +971,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select * from user where 1 != 1", "Query": "select * from user where id = 5 and name = true limit 5", "Table": "user", @@ -1041,7 +996,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1076,7 +1030,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -1121,7 +1074,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user.id as id1 from user where 1 != 1", "Query": "select user.id as id1 from user", "Table": "user" @@ -1133,7 +1085,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select user_extra.id as id2 from user_extra where 1 != 1", "Query": "select user_extra.id as id2 from user_extra", "Table": "user_extra" @@ -1179,7 +1130,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1201,7 +1151,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "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", @@ -1319,7 +1268,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select a from user_metadata as route1 where 1 != 1 union select b from user_metadata as route1 where 1 != 1", "Query": "select a from user_metadata as route1 where email = 'aaa' union select b from user_metadata as route1 where email = 'aaa'", "Table": "user_metadata", diff --git a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt index d0434dabf51..0dc84a6fa4a 100644 --- a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt @@ -17,7 +17,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select predef2 from user where 1 != 1", "Query": "select predef2 from user", "Table": "user" diff --git a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt index 35fe1ad903e..48e164f8bf4 100644 --- a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt @@ -200,7 +200,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from samecolvin where 1 != 1", "Query": "select col from samecolvin where col = :col", "Table": "samecolvin", diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt index ecf5cf8004e..7442fd73a24 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt @@ -15,7 +15,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id as uid from user as u where 1 != 1", "Query": "select u.id as uid from user as u", "Table": "user" @@ -27,7 +26,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid", "Table": "user_extra" @@ -53,7 +51,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id as uid from user as u where 1 != 1", "Query": "select u.id as uid from user as u", "Table": "user" @@ -65,7 +62,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.col, e.id as eid from user_extra as e where 1 != 1", "Query": "select e.col, e.id as eid from user_extra as e having eid = :uid1 and e.col = :uid", "Table": "user_extra" @@ -97,7 +93,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" @@ -109,7 +104,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2", "Table": "user" @@ -123,7 +117,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" @@ -155,7 +148,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u1.id from user as u1 where 1 != 1", "Query": "select u1.id from user as u1", "Table": "user" @@ -167,7 +159,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u2.col from user as u2 where 1 != 1", "Query": "select u2.col from user as u2", "Table": "user" @@ -181,7 +172,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u2_col", "Table": "user" @@ -213,7 +203,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" @@ -225,7 +214,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2 where u2.col = :u1_col", "Table": "user" @@ -239,7 +227,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.col = :u1_col", "Table": "user" @@ -280,7 +267,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" @@ -292,7 +278,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2", "Table": "user" @@ -306,7 +291,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.id = :u1_col", "Table": "user", @@ -324,7 +308,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u4 where 1 != 1", "Query": "select 1 from user as u4 where u4.col = :u1_col", "Table": "user" @@ -350,7 +333,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u1.id, u1.col from user as u1 where 1 != 1", "Query": "select u1.id, u1.col from user as u1", "Table": "user" @@ -367,7 +349,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u2 where 1 != 1", "Query": "select 1 from user as u2 where u2.id = :u1_col", "Table": "user", @@ -383,7 +364,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user as u3 where 1 != 1", "Query": "select 1 from user as u3 where u3.id = :u1_col", "Table": "user", @@ -415,7 +395,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name` where 1 != 1", "Query": "select `weird``name`.a, `weird``name`.`a``b*c` from `weird``name`", "Table": "weird`name" @@ -452,7 +431,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select `weird``name`.`a``b*c` from `weird``name` where 1 != 1", "Query": "select `weird``name`.`a``b*c` from `weird``name`", "Table": "weird`name" @@ -494,7 +472,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u", "Table": "user" @@ -506,7 +483,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra" @@ -543,7 +519,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id, u.col from user as u where 1 != 1", "Query": "select u.id, u.col from user as u", "Table": "user" @@ -555,7 +530,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra" @@ -571,7 +545,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select 1 from user where 1 != 1", "Query": "select 1 from user where :__sq_has_values1 = 1 and id in ::__vals", "Table": "user", @@ -604,7 +577,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select col from user where 1 != 1", "Query": "select col from user", "Table": "user" @@ -622,7 +594,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select u.id, :__sq1, u.col from user as u where 1 != 1", "Query": "select u.id, :__sq1, u.col from user as u", "Table": "user" @@ -634,7 +605,6 @@ "Name": "user", "Sharded": true }, - "TargetTabletType": "MASTER", "FieldQuery": "select e.id from user_extra as e where 1 != 1", "Query": "select e.id from user_extra as e where e.id = :u_col", "Table": "user_extra"