@@ -1241,6 +1241,37 @@ func TestAggPushDownCountStar(t *testing.T) {
1241
1241
tk .MustQuery ("select count(*) from c, o where c.c_id=o.c_id" ).Check (testkit .Rows ("5" ))
1242
1242
}
1243
1243
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
+
1244
1275
func TestGroupStreamAggOnTiFlash (t * testing.T ) {
1245
1276
store := testkit .CreateMockStore (t , withMockTiFlash (2 ))
1246
1277
tk := testkit .NewTestKit (t , store )
0 commit comments