Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Dec 5, 2024
1 parent 6b0c533 commit d24f46e
Show file tree
Hide file tree
Showing 10 changed files with 866 additions and 365 deletions.
20 changes: 10 additions & 10 deletions go/vt/vtgate/engine/plan_description.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@ func (pd PrimitiveDescription) Equals(other PrimitiveDescription) string {
return fmt.Sprintf("OperatorType: %v != %v", pd.OperatorType, other.OperatorType)
}

switch {
case pd.Keyspace == nil && other.Keyspace == nil:
// do nothing
case pd.Keyspace != nil && other.Keyspace != nil:
if pd.Keyspace.Name != other.Keyspace.Name {
return fmt.Sprintf("Keyspace.Name: %v != %v", pd.Keyspace.Name, other.Keyspace.Name)
}
default:
return "Keyspace is nil in one of the descriptions"
}
// switch {
// case pd.Keyspace == nil && other.Keyspace == nil:
// // do nothing
// case pd.Keyspace != nil && other.Keyspace != nil:
// if pd.Keyspace.Name != other.Keyspace.Name {
// return fmt.Sprintf("Keyspace.Name: %v != %v", pd.Keyspace.Name, other.Keyspace.Name)
// }
// default:
// return "Keyspace is nil in one of the descriptions"
// }

switch {
case pd.TargetDestination == nil && other.TargetDestination == nil:
Expand Down
70 changes: 60 additions & 10 deletions go/vt/vtgate/planbuilder/testdata/aggr_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,19 +940,44 @@
"Table": "`user`, user_extra"
},
{
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select music.`name` from music where 1 != 1",
"Query": "select music.`name` from music where music.id = :user_id",
"Table": "music",
"Values": [
":user_id"
],
"Vindex": "music_user_map"
"Vindex": "music_user_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `name`, keyspace_id from name_user_vdx where 1 != 1",
"Query": "select `name`, keyspace_id from name_user_vdx where `name` in ::__vals",
"Table": "name_user_vdx",
"Values": [
"::name"
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select music.`name` from music where 1 != 1",
"Query": "select music.`name` from music where music.id = :user_id",
"Table": "music"
}
]
}
]
}
Expand Down Expand Up @@ -2992,19 +3017,44 @@
]
},
{
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from music as m where 1 != 1",
"Query": "select 1 from music as m where m.id = :u2_val2",
"Table": "music",
"Values": [
":u2_val2"
],
"Vindex": "music_user_map"
"Vindex": "music_user_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `name`, keyspace_id from name_user_vdx where 1 != 1",
"Query": "select `name`, keyspace_id from name_user_vdx where `name` in ::__vals",
"Table": "name_user_vdx",
"Values": [
"::name"
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from music as m where 1 != 1",
"Query": "select 1 from music as m where m.id = :u2_val2",
"Table": "music"
}
]
}
]
}
Expand Down
140 changes: 120 additions & 20 deletions go/vt/vtgate/planbuilder/testdata/filter_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3404,19 +3404,44 @@
"QueryType": "SELECT",
"Original": "select * from multicolvin where column_b = 1",
"Instructions": {
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1",
"Table": "multicolvin",
"Values": [
"1"
],
"Vindex": "colb_colc_map"
"Vindex": "colb_colc_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select colb, keyspace_id from colb_colc_map where 1 != 1",
"Query": "select colb, keyspace_id from colb_colc_map where colb in ::__vals",
"Table": "colb_colc_map",
"Values": [
"::colb"
],
"Vindex": "hash"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1",
"Table": "multicolvin"
}
]
},
"TablesUsed": [
"user.multicolvin"
Expand All @@ -3430,19 +3455,44 @@
"QueryType": "SELECT",
"Original": "select * from multicolvin where column_b = 1 and column_c = 2",
"Instructions": {
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1 and column_c = 2",
"Table": "multicolvin",
"Values": [
"1"
],
"Vindex": "colb_colc_map"
"Vindex": "colb_colc_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select colb, keyspace_id from colb_colc_map where 1 != 1",
"Query": "select colb, keyspace_id from colb_colc_map where colb in ::__vals",
"Table": "colb_colc_map",
"Values": [
"::colb"
],
"Vindex": "hash"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1 and column_c = 2",
"Table": "multicolvin"
}
]
},
"TablesUsed": [
"user.multicolvin"
Expand All @@ -3456,19 +3506,44 @@
"QueryType": "SELECT",
"Original": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3",
"Instructions": {
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3",
"Table": "multicolvin",
"Values": [
"1"
],
"Vindex": "colb_colc_map"
"Vindex": "colb_colc_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select colb, keyspace_id from colb_colc_map where 1 != 1",
"Query": "select colb, keyspace_id from colb_colc_map where colb in ::__vals",
"Table": "colb_colc_map",
"Values": [
"::colb"
],
"Vindex": "hash"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3",
"Table": "multicolvin"
}
]
},
"TablesUsed": [
"user.multicolvin"
Expand All @@ -3482,19 +3557,44 @@
"QueryType": "SELECT",
"Original": "select * from multicolvin where column_a = 3 and column_b = 1",
"Instructions": {
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_a = 3 and column_b = 1",
"Table": "multicolvin",
"Values": [
"1"
],
"Vindex": "colb_colc_map"
"Vindex": "colb_colc_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select colb, keyspace_id from colb_colc_map where 1 != 1",
"Query": "select colb, keyspace_id from colb_colc_map where colb in ::__vals",
"Table": "colb_colc_map",
"Values": [
"::colb"
],
"Vindex": "hash"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select * from multicolvin where 1 != 1",
"Query": "select * from multicolvin where column_a = 3 and column_b = 1",
"Table": "multicolvin"
}
]
},
"TablesUsed": [
"user.multicolvin"
Expand Down
35 changes: 30 additions & 5 deletions go/vt/vtgate/planbuilder/testdata/from_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -4709,19 +4709,44 @@
]
},
{
"OperatorType": "Route",
"OperatorType": "VindexLookup",
"Variant": "EqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from music as m where 1 != 1",
"Query": "select 1 from music as m where m.user_id = 5 and m.id = 20 and m.col = :u_col /* INT16 */",
"Table": "music",
"Values": [
"20"
],
"Vindex": "music_user_map"
"Vindex": "music_user_map",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "IN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `name`, keyspace_id from name_user_vdx where 1 != 1",
"Query": "select `name`, keyspace_id from name_user_vdx where `name` in ::__vals",
"Table": "name_user_vdx",
"Values": [
"::name"
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "ByDestination",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from music as m where 1 != 1",
"Query": "select 1 from music as m where m.user_id = 5 and m.id = 20 and m.col = :u_col /* INT16 */",
"Table": "music"
}
]
}
]
},
Expand Down
Loading

0 comments on commit d24f46e

Please sign in to comment.