diff --git a/pkg/planner/core/casetest/BUILD.bazel b/pkg/planner/core/casetest/BUILD.bazel index a9cac84c4ba66..1f88dc86084d3 100644 --- a/pkg/planner/core/casetest/BUILD.bazel +++ b/pkg/planner/core/casetest/BUILD.bazel @@ -12,7 +12,7 @@ go_test( ], data = glob(["testdata/**"]), flaky = True, - shard_count = 20, + shard_count = 19, deps = [ "//pkg/domain", "//pkg/parser", diff --git a/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json b/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json index ca315171c41b6..f490b89030562 100644 --- a/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json +++ b/pkg/planner/core/casetest/enforcempp/testdata/enforce_mpp_suite_out.json @@ -188,14 +188,16 @@ { "SQL": "explain select /*+ read_from_storage(tiflash[t3]) */ * from t3 where sala='a' and id =1; -- once hinted, walk with tiflash range scan", "Plan": [ - "Point_Get_1 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) " + "TableReader_11 0.01 root partition:p1 MppVersion: 2, data:ExchangeSender_10", + "└─ExchangeSender_10 0.01 mpp[tiflash] ExchangeType: PassThrough", + " └─TableRangeScan_9 1.00 mpp[tiflash] table:t3 range:[1 \"a\",1 \"a\"], keep order:false, stats:pseudo, PartitionTableScan:true" ], "Warn": null }, { "SQL": "explain select * from t3 where sala='a' and id =1; -- once not hinted, walk with tikv point get", "Plan": [ - "Point_Get_1 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) " + "Point_Get_5 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) " ], "Warn": null } diff --git a/pkg/planner/core/casetest/integration_test.go b/pkg/planner/core/casetest/integration_test.go index 2d4eece042c84..85f3b942d3f54 100644 --- a/pkg/planner/core/casetest/integration_test.go +++ b/pkg/planner/core/casetest/integration_test.go @@ -385,47 +385,3 @@ func TestFixControl45132(t *testing.T) { tk.MustExec(`set @@tidb_opt_fix_control = "45132:0"`) tk.MustHavePlan(`select * from t where a=2`, `TableFullScan`) } - -func TestInvisibleIndex(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - - tk.MustExec("use test") - tk.MustExec("drop table if exists t") - - // Optimizer cannot see invisible indexes. - tk.MustExec("create table t(a int, b int, unique index i_a (a) invisible, unique index i_b(b))") - tk.MustExec("insert into t values (1,2)") - - // For issue 26217, can't use invisible index after admin check table. - tk.MustExec("admin check table t") - - // Optimizer cannot use invisible indexes. - tk.MustQuery("select a from t order by a").Check(testkit.Rows("1")) - require.False(t, tk.MustUseIndex("select a from t order by a", "i_a")) - tk.MustQuery("select a from t where a > 0").Check(testkit.Rows("1")) - require.False(t, tk.MustUseIndex("select a from t where a > 1", "i_a")) - - // If use invisible indexes in index hint and sql hint, throw an error. - errStr := "[planner:1176]Key 'i_a' doesn't exist in table 't'" - tk.MustGetErrMsg("select * from t use index(i_a)", errStr) - tk.MustGetErrMsg("select * from t force index(i_a)", errStr) - tk.MustGetErrMsg("select * from t ignore index(i_a)", errStr) - tk.MustQuery("select /*+ USE_INDEX(t, i_a) */ * from t") - require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1) - require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr) - tk.MustQuery("select /*+ IGNORE_INDEX(t, i_a), USE_INDEX(t, i_b) */ a from t order by a") - require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1) - require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr) - tk.MustQuery("select /*+ FORCE_INDEX(t, i_a), USE_INDEX(t, i_b) */ a from t order by a") - require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1) - require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr) - // For issue 15519 - inapplicableErrStr := "[planner:1815]force_index(test.aaa) is inapplicable, check whether the table(test.aaa) exists" - tk.MustQuery("select /*+ FORCE_INDEX(aaa) */ * from t") - require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1) - require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, inapplicableErrStr) - - tk.MustExec("admin check table t") - tk.MustExec("admin check index t i_a") -} diff --git a/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json b/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json index 71456e2d40833..8ae2b35395618 100644 --- a/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json +++ b/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json @@ -680,8 +680,8 @@ ], "StaticPlan": [ "PartitionUnion 2.00 root ", - "├─Batch_Point_Get 1.00 root table:t, partition:p1 handle:[1], keep order:false, desc:false", - "└─Batch_Point_Get 1.00 root table:t, partition:P2 handle:[2], keep order:false, desc:false" + "├─Batch_Point_Get 1.00 root table:t handle:[1 2], keep order:false, desc:false", + "└─Batch_Point_Get 1.00 root table:t handle:[1 2], keep order:false, desc:false" ] }, { @@ -887,7 +887,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false" + "Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -901,7 +901,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:true, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:true, desc:false" + "Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:true, desc:false" ], "Result": [ "1 1", @@ -915,7 +915,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:true, desc, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:true, desc:true" + "Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:true, desc:true" ], "Result": [ "2 1", @@ -930,8 +930,8 @@ ], "StaticPlan": [ "PartitionUnion 4.00 root ", - "├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false", - "└─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false" + "├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false", + "└─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -947,8 +947,8 @@ "StaticPlan": [ "Sort 4.00 root test.thash1.b", "└─PartitionUnion 4.00 root ", - " ├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false", - " └─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false" + " ├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false", + " └─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -964,8 +964,8 @@ "StaticPlan": [ "Sort 4.00 root test.thash1.b:desc", "└─PartitionUnion 4.00 root ", - " ├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false", - " └─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false" + " ├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false", + " └─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 2", @@ -1181,7 +1181,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false" + "Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -1195,7 +1195,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:true, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:true, desc:false" + "Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:true, desc:false" ], "Result": [ "1 1", @@ -1210,7 +1210,7 @@ " └─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:true, desc:true" + "Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:true, desc:true" ], "Result": [ "2 1", @@ -1225,8 +1225,8 @@ ], "StaticPlan": [ "PartitionUnion 0.04 root ", - "├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false", - "└─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false" + "├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false", + "└─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -1242,8 +1242,8 @@ "StaticPlan": [ "Sort 0.04 root test.thash2.b", "└─PartitionUnion 0.04 root ", - " ├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false", - " └─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false" + " ├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false", + " └─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 1", @@ -1260,8 +1260,8 @@ "StaticPlan": [ "Sort 0.04 root test.thash2.b:desc", "└─PartitionUnion 0.04 root ", - " ├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false", - " └─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false" + " ├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false", + " └─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Result": [ "1 2", @@ -1484,8 +1484,8 @@ ], "StaticPlan": [ "PartitionUnion 4.00 root ", - "├─Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[2], keep order:false, desc:false", - "└─Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1], keep order:false, desc:false" + "├─Batch_Point_Get 2.00 root table:thash3 handle:[1 2], keep order:false, desc:false", + "└─Batch_Point_Get 2.00 root table:thash3 handle:[1 2], keep order:false, desc:false" ], "Result": [ "1 0", @@ -1499,7 +1499,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:false, desc:false" + "Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:false, desc:false" ], "Result": [ "1 0", @@ -1513,7 +1513,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:true, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:true, desc:false" + "Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:true, desc:false" ], "Result": [ "1 0", @@ -1527,7 +1527,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:true, desc, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:true, desc:true" + "Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:true, desc:true" ], "Result": [ "3 0", @@ -1541,7 +1541,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [4,4], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[4], keep order:false, desc:false" + "Batch_Point_Get 2.00 root table:thash3 handle:[1 4], keep order:false, desc:false" ], "Result": [ "4 0" @@ -1565,7 +1565,7 @@ "└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[2,2], [4,4], keep order:false, stats:pseudo" ], "StaticPlan": [ - "Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[2 4], keep order:false, desc:false" + "Batch_Point_Get 2.00 root table:thash3 handle:[2 4], keep order:false, desc:false" ], "Result": [ "2 0", diff --git a/pkg/planner/core/casetest/windows/testdata/window_push_down_suite_out.json b/pkg/planner/core/casetest/windows/testdata/window_push_down_suite_out.json index cee5c05feb5eb..b94f57ef9c0cf 100644 --- a/pkg/planner/core/casetest/windows/testdata/window_push_down_suite_out.json +++ b/pkg/planner/core/casetest/windows/testdata/window_push_down_suite_out.json @@ -137,13 +137,12 @@ "└─Shuffle_27 10000.00 root execution info: concurrency:5, data sources:[Window_14]", " └─Window_12 10000.00 root sum(cast(Column#7, decimal(20,0) BINARY))->Column#9 over(partition by test.employee.deptid)", " └─Sort_26 10000.00 root test.employee.deptid", - " └─ShuffleReceiver_28 10000.00 root ", - " └─Window_14 10000.00 root row_number()->Column#7 over(order by Column#6 rows between current row and current row)", - " └─Sort_25 10000.00 root Column#6", - " └─Projection_19 10000.00 root test.employee.empid, test.employee.deptid, test.employee.salary, md5(cast(test.employee.deptid, var_string(20)))->Column#6", - " └─TableReader_24 10000.00 root MppVersion: 2, data:ExchangeSender_23", - " └─ExchangeSender_23 10000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TableFullScan_22 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" + " └─Window_14 10000.00 root row_number()->Column#7 over(order by Column#6 rows between current row and current row)", + " └─Sort_25 10000.00 root Column#6", + " └─Projection_19 10000.00 root test.employee.empid, test.employee.deptid, test.employee.salary, md5(cast(test.employee.deptid, var_string(20)))->Column#6", + " └─TableReader_24 10000.00 root MppVersion: 2, data:ExchangeSender_23", + " └─ExchangeSender_23 10000.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TableFullScan_22 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" ], "Warn": [ "MPP mode may be blocked because window function `sum` or its arguments are not supported now.", @@ -325,10 +324,9 @@ "Shuffle_15 10000.00 root execution info: concurrency:5, data sources:[TableReader_13]", "└─Window_8 10000.00 root sum(test.employee.salary)->Column#6 over(partition by test.employee.empid order by test.employee.salary range between 1 preceding and 1 following)", " └─Sort_14 10000.00 root test.employee.empid, test.employee.salary", - " └─ShuffleReceiver_16 10000.00 root ", - " └─TableReader_13 10000.00 root MppVersion: 2, data:ExchangeSender_12", - " └─ExchangeSender_12 10000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TableFullScan_11 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" + " └─TableReader_13 10000.00 root MppVersion: 2, data:ExchangeSender_12", + " └─ExchangeSender_12 10000.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TableFullScan_11 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" ], "Warn": [ "MPP mode may be blocked because window function `sum` or its arguments are not supported now.",