Skip to content

Commit 153eb96

Browse files
authored
planner: make TestMppAggShouldAlignFinalMode stable (#53566)
close #53565
1 parent e6d1899 commit 153eb96

File tree

3 files changed

+45
-54
lines changed

3 files changed

+45
-54
lines changed

pkg/executor/test/tiflashtest/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
],
1010
flaky = True,
1111
race = "on",
12-
shard_count = 42,
12+
shard_count = 43,
1313
deps = [
1414
"//pkg/config",
1515
"//pkg/domain",

pkg/executor/test/tiflashtest/tiflash_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,3 +1988,47 @@ func TestIssue50358(t *testing.T) {
19881988
tk.MustQuery("select 8 from t join t1").Check(testkit.Rows("8", "8"))
19891989
}
19901990
}
1991+
1992+
func TestMppAggShouldAlignFinalMode(t *testing.T) {
1993+
store := testkit.CreateMockStore(t, withMockTiFlash(1))
1994+
tk := testkit.NewTestKit(t, store)
1995+
tk.MustExec("use test")
1996+
tk.MustExec("create table t (" +
1997+
" d date," +
1998+
" v int," +
1999+
" primary key(d, v)" +
2000+
") partition by range columns (d) (" +
2001+
" partition p1 values less than ('2023-07-02')," +
2002+
" partition p2 values less than ('2023-07-03')" +
2003+
");")
2004+
tk.MustExec("alter table t set tiflash replica 1")
2005+
tb := external.GetTableByName(t, tk, "test", "t")
2006+
err := domain.GetDomain(tk.Session()).DDL().UpdateTableReplicaInfo(tk.Session(), tb.Meta().ID, true)
2007+
require.NoError(t, err)
2008+
tk.MustExec(`set tidb_partition_prune_mode='static';`)
2009+
err = failpoint.Enable("github.com/pingcap/tidb/pkg/expression/aggregation/show-agg-mode", "return(true)")
2010+
require.Nil(t, err)
2011+
2012+
tk.MustExec("set @@session.tidb_isolation_read_engines=\"tiflash\"")
2013+
tk.MustQuery("explain format='brief' select 1 from (" +
2014+
" select /*+ read_from_storage(tiflash[t]) */ sum(1)" +
2015+
" from t where d BETWEEN '2023-07-01' and '2023-07-03' group by d" +
2016+
") total;").Check(testkit.Rows("Projection 400.00 root 1->Column#4",
2017+
"└─HashAgg 400.00 root group by:test.t.d, funcs:count(complete,1)->Column#8",
2018+
" └─PartitionUnion 400.00 root ",
2019+
" ├─Projection 200.00 root test.t.d",
2020+
" │ └─HashAgg 200.00 root group by:test.t.d, funcs:firstrow(partial2,test.t.d)->test.t.d, funcs:count(final,Column#12)->Column#9",
2021+
" │ └─TableReader 200.00 root MppVersion: 2, data:ExchangeSender",
2022+
" │ └─ExchangeSender 200.00 mpp[tiflash] ExchangeType: PassThrough",
2023+
" │ └─HashAgg 200.00 mpp[tiflash] group by:test.t.d, funcs:count(partial1,1)->Column#12",
2024+
" │ └─TableRangeScan 250.00 mpp[tiflash] table:t, partition:p1 range:[2023-07-01,2023-07-03], keep order:false, stats:pseudo",
2025+
" └─Projection 200.00 root test.t.d",
2026+
" └─HashAgg 200.00 root group by:test.t.d, funcs:firstrow(partial2,test.t.d)->test.t.d, funcs:count(final,Column#14)->Column#10",
2027+
" └─TableReader 200.00 root MppVersion: 2, data:ExchangeSender",
2028+
" └─ExchangeSender 200.00 mpp[tiflash] ExchangeType: PassThrough",
2029+
" └─HashAgg 200.00 mpp[tiflash] group by:test.t.d, funcs:count(partial1,1)->Column#14",
2030+
" └─TableRangeScan 250.00 mpp[tiflash] table:t, partition:p2 range:[2023-07-01,2023-07-03], keep order:false, stats:pseudo"))
2031+
2032+
err = failpoint.Disable("github.com/pingcap/tidb/pkg/expression/aggregation/show-agg-mode")
2033+
require.Nil(t, err)
2034+
}

pkg/planner/core/enforce_mpp_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,65 +19,12 @@ import (
1919
"strconv"
2020
"testing"
2121

22-
"github.com/pingcap/failpoint"
2322
"github.com/pingcap/tidb/pkg/domain"
2423
"github.com/pingcap/tidb/pkg/parser/model"
2524
"github.com/pingcap/tidb/pkg/testkit"
2625
"github.com/stretchr/testify/require"
2726
)
2827

29-
func TestMppAggShouldAlignFinalMode(t *testing.T) {
30-
store := testkit.CreateMockStore(t)
31-
tk := testkit.NewTestKit(t, store)
32-
tk.MustExec("use test")
33-
tk.MustExec("create table t (" +
34-
" d date," +
35-
" v int," +
36-
" primary key(d, v)" +
37-
") partition by range columns (d) (" +
38-
" partition p1 values less than ('2023-07-02')," +
39-
" partition p2 values less than ('2023-07-03')" +
40-
");")
41-
// Create virtual tiflash replica info.
42-
dom := domain.GetDomain(tk.Session())
43-
is := dom.InfoSchema()
44-
db, exists := is.SchemaByName(model.NewCIStr("test"))
45-
require.True(t, exists)
46-
for _, tblInfo := range db.Tables {
47-
if tblInfo.Name.L == "t" {
48-
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
49-
Count: 1,
50-
Available: true,
51-
}
52-
}
53-
}
54-
tk.MustExec(`set tidb_partition_prune_mode='static';`)
55-
err := failpoint.Enable("github.com/pingcap/tidb/pkg/expression/aggregation/show-agg-mode", "return(true)")
56-
require.Nil(t, err)
57-
58-
tk.MustExec("set @@session.tidb_isolation_read_engines=\"tiflash\"")
59-
tk.MustQuery("explain format='brief' select 1 from (" +
60-
" select /*+ read_from_storage(tiflash[t]) */ sum(1)" +
61-
" from t where d BETWEEN '2023-07-01' and '2023-07-03' group by d" +
62-
") total;").Check(testkit.Rows("Projection 400.00 root 1->Column#4",
63-
"└─HashAgg 400.00 root group by:test.t.d, funcs:count(complete,1)->Column#8",
64-
" └─PartitionUnion 400.00 root ",
65-
" ├─Projection 200.00 root test.t.d",
66-
" │ └─HashAgg 200.00 root group by:test.t.d, funcs:firstrow(partial2,test.t.d)->test.t.d, funcs:count(final,Column#12)->Column#9",
67-
" │ └─TableReader 200.00 root MppVersion: 2, data:ExchangeSender",
68-
" │ └─ExchangeSender 200.00 mpp[tiflash] ExchangeType: PassThrough",
69-
" │ └─HashAgg 200.00 mpp[tiflash] group by:test.t.d, funcs:count(partial1,1)->Column#12",
70-
" │ └─TableRangeScan 250.00 mpp[tiflash] table:t, partition:p1 range:[2023-07-01,2023-07-03], keep order:false, stats:pseudo",
71-
" └─Projection 200.00 root test.t.d",
72-
" └─HashAgg 200.00 root group by:test.t.d, funcs:firstrow(partial2,test.t.d)->test.t.d, funcs:count(final,Column#14)->Column#10",
73-
" └─TableReader 200.00 root MppVersion: 2, data:ExchangeSender",
74-
" └─ExchangeSender 200.00 mpp[tiflash] ExchangeType: PassThrough",
75-
" └─HashAgg 200.00 mpp[tiflash] group by:test.t.d, funcs:count(partial1,1)->Column#14",
76-
" └─TableRangeScan 250.00 mpp[tiflash] table:t, partition:p2 range:[2023-07-01,2023-07-03], keep order:false, stats:pseudo"))
77-
78-
err = failpoint.Disable("github.com/pingcap/tidb/pkg/expression/aggregation/show-agg-mode")
79-
require.Nil(t, err)
80-
}
8128
func TestRowSizeInMPP(t *testing.T) {
8229
store := testkit.CreateMockStore(t)
8330
tk := testkit.NewTestKit(t, store)

0 commit comments

Comments
 (0)