Skip to content

Commit 55cf58b

Browse files
authored
Cascades Planner: add vector, window plan cases covering cascades mode (pingcap#62786)
ref pingcap#62328
1 parent 3fc9a4a commit 55cf58b

File tree

4 files changed

+1158
-126
lines changed

4 files changed

+1158
-126
lines changed

pkg/planner/core/casetest/partition/partition_pruner_test.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,15 @@ func TestListColumnsPartitionPruner(t *testing.T) {
125125
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
126126
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
127127
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
128-
store := testkit.CreateMockStore(t)
129-
tk := testkit.NewTestKit(t, store)
128+
store := testKit.Session().GetStore()
130129

131-
tk.MustExec("drop database if exists test_partition;")
132-
tk.MustExec("create database test_partition")
133-
tk.MustExec("use test_partition")
134-
tk.MustExec("create table t1 (id int, a int, b int) partition by list columns (b,a) (partition p0 values in ((1,1),(2,2),(3,3),(4,4),(5,5)), partition p1 values in ((6,6),(7,7),(8,8),(9,9),(10,10),(null,10)));")
135-
tk.MustExec("create table t2 (id int, a int, b int) partition by list columns (id,a,b) (partition p0 values in ((1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5)), partition p1 values in ((6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,null,null)));")
136-
tk.MustExec("insert into t1 (id,a,b) values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,10,null)")
137-
tk.MustExec("insert into t2 (id,a,b) values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,null,null)")
130+
testKit.MustExec("drop database if exists test_partition;")
131+
testKit.MustExec("create database test_partition")
132+
testKit.MustExec("use test_partition")
133+
testKit.MustExec("create table t1 (id int, a int, b int) partition by list columns (b,a) (partition p0 values in ((1,1),(2,2),(3,3),(4,4),(5,5)), partition p1 values in ((6,6),(7,7),(8,8),(9,9),(10,10),(null,10)));")
134+
testKit.MustExec("create table t2 (id int, a int, b int) partition by list columns (id,a,b) (partition p0 values in ((1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5)), partition p1 values in ((6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,null,null)));")
135+
testKit.MustExec("insert into t1 (id,a,b) values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,10,null)")
136+
testKit.MustExec("insert into t2 (id,a,b) values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),(null,null,null)")
138137

139138
// tk1 use to test partition table with index.
140139
tk1 := testkit.NewTestKit(t, store)
@@ -160,6 +159,12 @@ func TestListColumnsPartitionPruner(t *testing.T) {
160159

161160
// Default RPC encoding may cause statistics explain result differ and then the test unstable.
162161
tk1.MustExec("set @@tidb_enable_chunk_rpc = on")
162+
cascadesVal := "off"
163+
if cascades == "on" {
164+
cascadesVal = "on"
165+
}
166+
tk1.MustExec(fmt.Sprintf("set @@tidb_enable_cascades_planner = %s", cascadesVal))
167+
tk2.MustExec(fmt.Sprintf("set @@tidb_enable_cascades_planner = %s", cascadesVal))
163168

164169
var input []struct {
165170
SQL string
@@ -176,14 +181,14 @@ func TestListColumnsPartitionPruner(t *testing.T) {
176181
valid := false
177182
for i, tt := range input {
178183
// Test for table without index.
179-
plan := tk.MustQuery("explain format = 'brief' " + tt.SQL)
184+
plan := testKit.MustQuery("explain format = 'brief' " + tt.SQL)
180185
planTree := testdata.ConvertRowsToStrings(plan.Rows())
181186
// Test for table with index.
182187
indexPlan := tk1.MustQuery("explain format = 'brief' " + tt.SQL)
183188
indexPlanTree := testdata.ConvertRowsToStrings(indexPlan.Rows())
184189
testdata.OnRecord(func() {
185190
output[i].SQL = tt.SQL
186-
output[i].Result = testdata.ConvertRowsToStrings(tk.MustQuery(tt.SQL).Sort().Rows())
191+
output[i].Result = testdata.ConvertRowsToStrings(testKit.MustQuery(tt.SQL).Sort().Rows())
187192
// Test for table without index.
188193
output[i].Plan = planTree
189194
// Test for table with index.
@@ -198,7 +203,7 @@ func TestListColumnsPartitionPruner(t *testing.T) {
198203
checkPrunePartitionInfo(t, tt.SQL, tt.Pruner, indexPlanTree)
199204

200205
// compare the result.
201-
result := tk.MustQuery(tt.SQL).Sort()
206+
result := testKit.MustQuery(tt.SQL).Sort()
202207
idxResult := tk1.MustQuery(tt.SQL)
203208
result.Check(idxResult.Sort().Rows())
204209
result.Check(testkit.Rows(output[i].Result...))

pkg/planner/core/casetest/vectorsearch/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestMain(m *testing.M) {
3131
testsetup.SetupForCommonTest()
3232

3333
flag.Parse()
34-
testDataMap.LoadTestSuiteData("testdata", "ann_index_suite")
34+
testDataMap.LoadTestSuiteData("testdata", "ann_index_suite", true)
3535
config.UpdateGlobal(func(conf *config.Config) {
3636
conf.TiKVClient.AsyncCommit.SafeWindow = 0
3737
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0

0 commit comments

Comments
 (0)