Skip to content

Commit

Permalink
cherry pick pingcap#24180 to release-5.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
guo-shaoge authored and ti-srebot committed Apr 25, 2021
1 parent 1145e34 commit 3ed911a
Show file tree
Hide file tree
Showing 4 changed files with 410 additions and 0 deletions.
24 changes: 24 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3019,6 +3019,30 @@ func (s *testIntegrationSerialSuite) TestMppAggWithJoin(c *C) {
}
}

<<<<<<< HEAD
=======
func (s *testIntegrationSerialSuite) TestLimitIndexLookUpKeepOrder(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a int, b int, c int, d int, index idx(a,b,c));")

var input []string
var output []struct {
SQL string
Plan []string
}
s.testData.GetTestCases(c, &input, &output)
for i, tt := range input {
s.testData.OnRecord(func() {
output[i].SQL = tt
output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
})
tk.MustQuery(tt).Check(testkit.Rows(output[i].Plan...))
}
}

>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180)
func (s *testIntegrationSuite) TestDecorrelateInnerJoinInSubquery(c *C) {
tk := testkit.NewTestKit(c, s.store)

Expand Down
23 changes: 23 additions & 0 deletions planner/core/testdata/integration_serial_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,30 @@
"desc format = 'brief' select * from t join ( select /*+ hash_agg()*/ count(*) as a from t) as A on A.a = t.id",
"desc format = 'brief' select sum(b) from (select t.id, t1.id as b from t join t t1 on t.id=t1.id)A group by id",
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(value),id from t group by id)B on C.id=B.id",
<<<<<<< HEAD
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id"
=======
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value limit 1",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value % 100 limit 1",
"desc format = 'brief' select count(*) from (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 20) v group by v.v1"
]
},
{
"name": "TestIndexMerge",
"cases": [
"desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and b+2>1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and length(b)=1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(a)=1) or (b=1 and length(b)=1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(b)=1) or (b=1 and length(a)=1)"
]
},
{
"name": "TestLimitIndexLookUpKeepOrder",
"cases": [
"desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b,c limit 10",
"desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b desc, c desc limit 10"
>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180)
]
}
]
Loading

0 comments on commit 3ed911a

Please sign in to comment.