|
15 | 15 | package vectorsearch
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "context" |
18 | 19 | "strings"
|
19 | 20 | "testing"
|
20 | 21 | "time"
|
21 | 22 |
|
22 | 23 | "github.com/pingcap/tidb/pkg/domain"
|
23 | 24 | "github.com/pingcap/tidb/pkg/domain/infosync"
|
24 | 25 | "github.com/pingcap/tidb/pkg/meta/model"
|
| 26 | + pmodel "github.com/pingcap/tidb/pkg/parser/model" |
25 | 27 | "github.com/pingcap/tidb/pkg/planner/core"
|
26 | 28 | "github.com/pingcap/tidb/pkg/planner/core/base"
|
27 | 29 | "github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
|
@@ -161,7 +163,7 @@ func TestANNIndexNormalizedPlan(t *testing.T) {
|
161 | 163 |
|
162 | 164 | tk.MustExec("analyze table t")
|
163 | 165 |
|
164 |
| - tk.MustExec("set @@tidb_isolation_read_engines = 'tiflash'") |
| 166 | + tk.MustExec("set @@tidb_isolation_read_engines = 'tiflash, tikv'") |
165 | 167 |
|
166 | 168 | tk.MustExec("explain select * from t order by vec_cosine_distance(vec, '[0,0,0]') limit 1")
|
167 | 169 | p1, d1 := getNormalizedPlan()
|
@@ -190,6 +192,25 @@ func TestANNIndexNormalizedPlan(t *testing.T) {
|
190 | 192 | require.Equal(t, d1, d2)
|
191 | 193 | require.Equal(t, d1, d3)
|
192 | 194 | require.NotEqual(t, d1, dx1)
|
| 195 | + |
| 196 | + // test for TiFlashReplica's Available |
| 197 | + tbl, err := dom.InfoSchema().TableByName(context.Background(), pmodel.NewCIStr("test"), pmodel.NewCIStr("t")) |
| 198 | + require.NoError(t, err) |
| 199 | + tbl.Meta().TiFlashReplica.Available = false |
| 200 | + tk.MustExec("explain select * from t order by vec_cosine_distance(vec, '[1,2,3]') limit 3") |
| 201 | + p2, _ := getNormalizedPlan() |
| 202 | + require.Equal(t, []string{ |
| 203 | + " Projection root test.t.vec", |
| 204 | + " └─TopN root ?", |
| 205 | + " └─Projection root test.t.vec, vec_cosine_distance(test.t.vec, ?)", |
| 206 | + " └─TableReader root ", |
| 207 | + " └─TopN cop vec_cosine_distance(test.t.vec, ?)", |
| 208 | + " └─TableFullScan cop table:t, range:[?,?], keep order:false", |
| 209 | + }, p2) |
| 210 | + tbl.Meta().TiFlashReplica.Available = true |
| 211 | + tk.MustExec("explain select * from t order by vec_cosine_distance(vec, '[1,2,3]') limit 3") |
| 212 | + _, d4 := getNormalizedPlan() |
| 213 | + require.Equal(t, d1, d4) |
193 | 214 | }
|
194 | 215 |
|
195 | 216 | func TestANNInexWithSimpleCBO(t *testing.T) {
|
|
0 commit comments