You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
utils.AssertMatches(t, conn, "select id from t10 WHERE (col1, id) IN (('bar', 1), ('baz', 2), ('qux', 3), ('barbar', 4))", "[[INT64(1)]]")
566
+
utils.AssertMatches(t, conn, "select id from t10 WHERE (col1 = 'bar' AND id = 1) OR (col1 = 'baz' AND id = 2) OR (col1 = 'qux' AND id = 3) OR (col1 = 'barbar' AND id = 4)", "[[INT64(1)]]")
}), "select nv_lu_col, other from t2_lookup WHERE (nv_lu_col = 1 AND other = 'bar') OR (nv_lu_col = 2 AND other = 'baz') OR (nv_lu_col = 3 AND other = 'qux') OR (nv_lu_col = 4 AND other = 'brz') OR (nv_lu_col = 5 AND other = 'brz')")
3034
+
3035
+
require.NoError(t, err)
3036
+
3037
+
// We end up doing a scatter query here, so no queries are sent to the lookup table
3038
+
require.Len(t, sbclookup.Queries, 0)
3039
+
require.Len(t, sbcs[0].Queries, 1)
3040
+
require.Len(t, sbcs[1].Queries, 1)
3041
+
require.Len(t, sbcs[2].Queries, 1)
3042
+
require.Len(t, sbcs[3].Queries, 1)
3043
+
require.Len(t, sbcs[4].Queries, 1)
3044
+
require.Len(t, sbcs[5].Queries, 1)
3045
+
require.Len(t, sbcs[6].Queries, 1)
3046
+
require.Len(t, sbcs[7].Queries, 1)
3047
+
3048
+
for_, sbc:=rangesbcs {
3049
+
require.Equal(t, []*querypb.BoundQuery{{
3050
+
Sql: "select nv_lu_col, other from t2_lookup where nv_lu_col = 1 and other = 'bar' or nv_lu_col = 2 and other = 'baz' or nv_lu_col = 3 and other = 'qux' or nv_lu_col = 4 and other = 'brz' or nv_lu_col = 5 and other = 'brz'",
Copy file name to clipboardExpand all lines: go/vt/vtgate/planbuilder/testdata/filter_cases.json
+73Lines changed: 73 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -797,6 +797,79 @@
797
797
]
798
798
}
799
799
},
800
+
{
801
+
"comment": "Disjunction of conjunctions with 4 or more disjunctions",
802
+
"query": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff') OR (col = 'gg' AND name = 'hh')",
803
+
"plan": {
804
+
"QueryType": "SELECT",
805
+
"Original": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff') OR (col = 'gg' AND name = 'hh')",
806
+
"Instructions": {
807
+
"OperatorType": "Route",
808
+
"Variant": "Scatter",
809
+
"Keyspace": {
810
+
"Name": "user",
811
+
"Sharded": true
812
+
},
813
+
"FieldQuery": "select id from `user` where 1 != 1",
814
+
"Query": "select id from `user` where col = 'aa' and `name` = 'bb' or col = 'cc' and `name` = 'dd' or col = 'ee' and `name` = 'ff' or col = 'gg' and `name` = 'hh'",
815
+
"Table": "`user`"
816
+
},
817
+
"TablesUsed": [
818
+
"user.user"
819
+
]
820
+
}
821
+
},
822
+
{
823
+
"comment": "Disjunction of conjunctions with 3 or less disjunctions",
824
+
"query": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff')",
825
+
"plan": {
826
+
"QueryType": "SELECT",
827
+
"Original": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff')",
"FieldQuery": "select `name`, keyspace_id from name_user_vdx where 1 != 1",
848
+
"Query": "select `name`, keyspace_id from name_user_vdx where `name` in ::__vals",
849
+
"Table": "name_user_vdx",
850
+
"Values": [
851
+
"::name"
852
+
],
853
+
"Vindex": "user_index"
854
+
},
855
+
{
856
+
"OperatorType": "Route",
857
+
"Variant": "ByDestination",
858
+
"Keyspace": {
859
+
"Name": "user",
860
+
"Sharded": true
861
+
},
862
+
"FieldQuery": "select id from `user` where 1 != 1",
863
+
"Query": "select id from `user` where col in ('aa', 'cc', 'ee') and (col in ('aa', 'cc') or `name` = 'ff') and (col = 'aa' or `name` = 'dd' or col = 'ee') and (col = 'aa' or `name` = 'dd' or `name` = 'ff') and (`name` = 'bb' or col = 'cc' or col = 'ee') and (`name` = 'bb' or col = 'cc' or `name` = 'ff') and (`name` in ('bb', 'dd') or col = 'ee') and `name` in ::__vals",
864
+
"Table": "`user`"
865
+
}
866
+
]
867
+
},
868
+
"TablesUsed": [
869
+
"user.user"
870
+
]
871
+
}
872
+
},
800
873
{
801
874
"comment": "Single table complex in clause",
802
875
"query": "select id from user where name in (col, 'bb')",
0 commit comments