Skip to content

Commit 2358fa4

Browse files
AilinKidti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#46310
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
1 parent 4cb399e commit 2358fa4

File tree

6 files changed

+2322
-2
lines changed

6 files changed

+2322
-2
lines changed

executor/tiflashtest/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ go_test(
99
],
1010
flaky = True,
1111
race = "on",
12+
<<<<<<< HEAD:executor/tiflashtest/BUILD.bazel
1213
shard_count = 37,
14+
=======
15+
shard_count = 39,
16+
>>>>>>> 4facc136b5e (planner: fix wrong result when pushing Agg down through Union in MPP plans (#46310)):executor/test/tiflashtest/BUILD.bazel
1317
deps = [
1418
"//config",
1519
"//domain",

executor/tiflashtest/tiflash_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,37 @@ func TestAggPushDownCountStar(t *testing.T) {
12411241
tk.MustQuery("select count(*) from c, o where c.c_id=o.c_id").Check(testkit.Rows("5"))
12421242
}
12431243

1244+
func TestAggPushDownUnionAndMPP(t *testing.T) {
1245+
store := testkit.CreateMockStore(t, withMockTiFlash(2))
1246+
tk := testkit.NewTestKit(t, store)
1247+
1248+
tk.MustExec("use test")
1249+
tk.MustExec("create table t (a int, b int)")
1250+
tk.MustExec("alter table t set tiflash replica 1")
1251+
tk.MustExec("insert into t values (1, 1);")
1252+
tk.MustExec("insert into t values (1, 1);")
1253+
tk.MustExec("insert into t values (1, 1);")
1254+
tk.MustExec("insert into t values (1, 1);")
1255+
tk.MustExec("insert into t values (1, 1);")
1256+
tk.MustExec("set @@tidb_allow_mpp=1;")
1257+
tk.MustExec("set @@tidb_enforce_mpp=1;")
1258+
tk.MustExec("set @@tidb_opt_agg_push_down=1")
1259+
1260+
tk.MustExec("create table c(c_id int)")
1261+
tk.MustExec("create table o(o_id int, c_id int)")
1262+
tk.MustExec("insert into c values(1),(1),(1),(1)")
1263+
tk.MustExec("insert into o values(1,1),(1,1),(1,2)")
1264+
tk.MustExec("alter table c set tiflash replica 1")
1265+
tk.MustExec("alter table o set tiflash replica 1")
1266+
1267+
tk.MustQuery("select a, count(*) from (select a, b from t " +
1268+
"union all " +
1269+
"select a, b from t" +
1270+
") t group by a order by a limit 10;").Check(testkit.Rows("1 10"))
1271+
1272+
tk.MustQuery("select o.o_id, count(*) from c, o where c.c_id=o.o_id group by o.o_id").Check(testkit.Rows("1 12"))
1273+
}
1274+
12441275
func TestGroupStreamAggOnTiFlash(t *testing.T) {
12451276
store := testkit.CreateMockStore(t, withMockTiFlash(2))
12461277
tk := testkit.NewTestKit(t, store)

planner/core/casetest/enforce_mpp_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,20 @@ func TestMPP2PhaseAggPushDown(t *testing.T) {
345345
tk.MustExec("create table c(c_id bigint)")
346346
tk.MustExec("create table o(o_id bigint, c_id bigint not null)")
347347

348+
tk.MustExec("create table t (a int, b int)")
349+
tk.MustExec("insert into t values (1, 1);")
350+
tk.MustExec("insert into t values (1, 1);")
351+
tk.MustExec("insert into t values (1, 1);")
352+
tk.MustExec("insert into t values (1, 1);")
353+
tk.MustExec("insert into t values (1, 1);")
354+
348355
// Create virtual tiflash replica info.
349356
dom := domain.GetDomain(tk.Session())
350357
is := dom.InfoSchema()
351358
db, exists := is.SchemaByName(model.NewCIStr("test"))
352359
require.True(t, exists)
353360
for _, tblInfo := range db.Tables {
354-
if tblInfo.Name.L == "c" || tblInfo.Name.L == "o" {
361+
if tblInfo.Name.L == "c" || tblInfo.Name.L == "o" || tblInfo.Name.L == "t" {
355362
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
356363
Count: 1,
357364
Available: true,

0 commit comments

Comments
 (0)