@@ -1248,6 +1248,37 @@ func TestAggPushDownCountStar(t *testing.T) {
1248
1248
tk .MustQuery ("select count(*) from c, o where c.c_id=o.c_id" ).Check (testkit .Rows ("5" ))
1249
1249
}
1250
1250
1251
+ func TestAggPushDownUnionAndMPP (t * testing.T ) {
1252
+ store := testkit .CreateMockStore (t , withMockTiFlash (2 ))
1253
+ tk := testkit .NewTestKit (t , store )
1254
+
1255
+ tk .MustExec ("use test" )
1256
+ tk .MustExec ("create table t (a int, b int)" )
1257
+ tk .MustExec ("alter table t set tiflash replica 1" )
1258
+ tk .MustExec ("insert into t values (1, 1);" )
1259
+ tk .MustExec ("insert into t values (1, 1);" )
1260
+ tk .MustExec ("insert into t values (1, 1);" )
1261
+ tk .MustExec ("insert into t values (1, 1);" )
1262
+ tk .MustExec ("insert into t values (1, 1);" )
1263
+ tk .MustExec ("set @@tidb_allow_mpp=1;" )
1264
+ tk .MustExec ("set @@tidb_enforce_mpp=1;" )
1265
+ tk .MustExec ("set @@tidb_opt_agg_push_down=1" )
1266
+
1267
+ tk .MustExec ("create table c(c_id int)" )
1268
+ tk .MustExec ("create table o(o_id int, c_id int)" )
1269
+ tk .MustExec ("insert into c values(1),(1),(1),(1)" )
1270
+ tk .MustExec ("insert into o values(1,1),(1,1),(1,2)" )
1271
+ tk .MustExec ("alter table c set tiflash replica 1" )
1272
+ tk .MustExec ("alter table o set tiflash replica 1" )
1273
+
1274
+ tk .MustQuery ("select a, count(*) from (select a, b from t " +
1275
+ "union all " +
1276
+ "select a, b from t" +
1277
+ ") t group by a order by a limit 10;" ).Check (testkit .Rows ("1 10" ))
1278
+
1279
+ 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" ))
1280
+ }
1281
+
1251
1282
func TestGroupStreamAggOnTiFlash (t * testing.T ) {
1252
1283
store , clean := testkit .CreateMockStore (t , withMockTiFlash (2 ))
1253
1284
defer clean ()
0 commit comments