Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: remove the same projection when to InjectExtraProjection | tidb-test=pr/2349 #54163

Merged
merged 8 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.t.a, Column#4",
" └─Projection 8000.00 mpp[tiflash] Column#4, test.t.a",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#7, funcs:sum(Column#5)->Column#4, funcs:firstrow(Column#6)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#5, test.t.a->Column#6, test.t.a->Column#7",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#6, funcs:sum(Column#5)->Column#4, funcs:firstrow(Column#6)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#5, test.t.a->Column#6",
" └─ExchangeReceiver 10000.00 mpp[tiflash] ",
" └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary]",
" └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@
"└─ExchangeSender 2.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 2.00 mpp[tiflash] test.table_1.id, Column#4, Column#5",
" └─Projection 2.00 mpp[tiflash] div(Column#4, cast(case(eq(Column#20, 0), 1, Column#20), decimal(20,0) BINARY))->Column#4, div(Column#5, cast(case(eq(Column#21, 0), 1, Column#21), decimal(20,0) BINARY))->Column#5, test.table_1.id",
" └─HashAgg 2.00 mpp[tiflash] group by:Column#34, funcs:count(Column#29)->Column#20, funcs:sum(Column#30)->Column#4, funcs:count(Column#31)->Column#21, funcs:sum(Column#32)->Column#5, funcs:firstrow(Column#33)->test.table_1.id",
" └─Projection 2.00 mpp[tiflash] plus(test.table_1.value, 1)->Column#29, plus(test.table_1.value, 1)->Column#30, test.table_1.value->Column#31, test.table_1.value->Column#32, test.table_1.id->Column#33, test.table_1.id->Column#34",
" └─HashAgg 2.00 mpp[tiflash] group by:Column#33, funcs:count(Column#29)->Column#20, funcs:sum(Column#30)->Column#4, funcs:count(Column#31)->Column#21, funcs:sum(Column#32)->Column#5, funcs:firstrow(Column#33)->test.table_1.id",
" └─Projection 2.00 mpp[tiflash] plus(test.table_1.value, 1)->Column#29, plus(test.table_1.value, 1)->Column#30, test.table_1.value->Column#31, test.table_1.value->Column#32, test.table_1.id->Column#33",
" └─ExchangeReceiver 2.00 mpp[tiflash] ",
" └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.table_1.id, collate: binary]",
" └─TableFullScan 2.00 mpp[tiflash] table:table_1 keep order:false"
Expand Down Expand Up @@ -2124,8 +2124,8 @@
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t pushed down filter:empty, keep order:false, stats:pseudo",
" └─Projection(Probe) 7992.00 mpp[tiflash] Column#11, test.t.id",
" └─HashAgg 7992.00 mpp[tiflash] group by:Column#39, funcs:sum(Column#37)->Column#11, funcs:firstrow(Column#38)->test.t.id",
" └─Projection 9990.00 mpp[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#37, test.t.id->Column#38, test.t.id->Column#39",
" └─HashAgg 7992.00 mpp[tiflash] group by:Column#38, funcs:sum(Column#37)->Column#11, funcs:firstrow(Column#38)->test.t.id",
" └─Projection 9990.00 mpp[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#37, test.t.id->Column#38",
" └─Projection 9990.00 mpp[tiflash] test.t.id, test.t.id",
" └─HashJoin 9990.00 mpp[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]",
" ├─Projection(Build) 7992.00 mpp[tiflash] test.t.id, Column#13",
Expand Down Expand Up @@ -2430,8 +2430,8 @@
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t pushed down filter:empty, keep order:false, stats:pseudo",
" └─Projection(Probe) 7992.00 mpp[tiflash] Column#11, test.t.id",
" └─HashAgg 7992.00 mpp[tiflash] group by:Column#34, funcs:sum(Column#32)->Column#11, funcs:firstrow(Column#33)->test.t.id",
" └─Projection 9990.00 mpp[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#32, test.t.id->Column#33, test.t.id->Column#34",
" └─HashAgg 7992.00 mpp[tiflash] group by:Column#33, funcs:sum(Column#32)->Column#11, funcs:firstrow(Column#33)->test.t.id",
" └─Projection 9990.00 mpp[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#32, test.t.id->Column#33",
" └─ExchangeReceiver 9990.00 mpp[tiflash] ",
" └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.id, collate: binary]",
" └─Projection 9990.00 mpp[tiflash] test.t.id, test.t.id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.t.a, Column#5",
" └─Projection 8000.00 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#10, Column#11, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.a->Column#10, test.t.c->Column#11",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#10, Column#9, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.c->Column#10",
" └─ExchangeReceiver 10000.00 mpp[tiflash] ",
" └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down Expand Up @@ -72,8 +72,8 @@
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.t.a, Column#5",
" └─Projection 8000.00 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#8, Column#9, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.a->Column#8, test.t.c->Column#9",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#7, Column#8, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.c->Column#8",
" └─ExchangeReceiver 10000.00 mpp[tiflash] ",
" └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down Expand Up @@ -329,8 +329,8 @@
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.t.a, Column#5",
" └─Projection 8000.00 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#8, Column#9, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.a->Column#8, test.t.c->Column#9",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#7, Column#8, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.c->Column#8",
" └─ExchangeReceiver 10000.00 mpp[tiflash] ",
" └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down Expand Up @@ -375,8 +375,8 @@
"└─ExchangeSender 2666.67 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 2666.67 mpp[tiflash] test.t.a, Column#5",
" └─Projection 2666.67 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg 2666.67 mpp[tiflash] group by:Column#8, Column#9, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 3333.33 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.a->Column#8, test.t.c->Column#9",
" └─HashAgg 2666.67 mpp[tiflash] group by:Column#7, Column#8, funcs:sum(Column#6)->Column#5, funcs:firstrow(Column#7)->test.t.a",
" └─Projection 3333.33 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#6, test.t.a->Column#7, test.t.c->Column#8",
" └─ExchangeReceiver 3333.33 mpp[tiflash] ",
" └─ExchangeSender 3333.33 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─Selection 3333.33 mpp[tiflash] gt(test.t.a, 1)",
Expand Down Expand Up @@ -513,8 +513,8 @@
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.t.a, Column#5",
" └─Projection 8000.00 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#10, Column#11, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.a->Column#10, test.t.c->Column#11",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#10, Column#9, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.c->Column#10",
" └─ExchangeReceiver 10000.00 mpp[tiflash] ",
" └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down Expand Up @@ -623,8 +623,8 @@
" ├─ExchangeReceiver(Build) 7992.00 mpp[tiflash] ",
" │ └─ExchangeSender 7992.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Projection 7992.00 mpp[tiflash] Column#9, test.t.b",
" │ └─HashAgg 7992.00 mpp[tiflash] group by:Column#26, funcs:sum(Column#24)->Column#9, funcs:firstrow(Column#25)->test.t.b",
" │ └─Projection 9990.00 mpp[tiflash] cast(test.t.a, decimal(10,0) BINARY)->Column#24, test.t.b->Column#25, test.t.b->Column#26",
" │ └─HashAgg 7992.00 mpp[tiflash] group by:Column#25, funcs:sum(Column#24)->Column#9, funcs:firstrow(Column#25)->test.t.b",
" │ └─Projection 9990.00 mpp[tiflash] cast(test.t.a, decimal(10,0) BINARY)->Column#24, test.t.b->Column#25",
" │ └─ExchangeReceiver 9990.00 mpp[tiflash] ",
" │ └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.b, collate: binary]",
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.b))",
Expand Down Expand Up @@ -1172,8 +1172,8 @@
"└─ExchangeSender_30 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection_5 8000.00 mpp[tiflash] test.t.a, Column#5",
" └─Projection_29 8000.00 mpp[tiflash] Column#5, test.t.a",
" └─HashAgg_27 8000.00 mpp[tiflash] group by:Column#10, Column#11, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection_32 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.a->Column#10, test.t.c->Column#11",
" └─HashAgg_27 8000.00 mpp[tiflash] group by:Column#10, Column#9, funcs:sum(Column#8)->Column#5, funcs:firstrow(Column#9)->test.t.a",
" └─Projection_32 10000.00 mpp[tiflash] cast(test.t.b, decimal(10,0) BINARY)->Column#8, test.t.a->Column#9, test.t.c->Column#10",
" └─ExchangeReceiver_23 10000.00 mpp[tiflash] ",
" └─ExchangeSender_22 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.a, collate: binary], [name: test.t.c, collate: binary]",
" └─TableFullScan_21 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
Expand Down Expand Up @@ -2594,8 +2594,8 @@
{
"SQL": "select /*+ agg_to_cop */ group_concat(name ORDER BY name desc SEPARATOR '++'), group_concat(id ORDER BY name desc, id asc SEPARATOR '--') from test;",
"Plan": [
"HashAgg 1.00 root funcs:group_concat(Column#6 order by Column#7 desc separator \"++\")->Column#4, funcs:group_concat(Column#8 order by Column#9 desc, Column#10 separator \"--\")->Column#5",
"└─Projection 10000.00 root cast(test.test.name, var_string(20))->Column#6, test.test.name->Column#7, cast(test.test.id, var_string(20))->Column#8, test.test.name->Column#9, test.test.id->Column#10",
"HashAgg 1.00 root funcs:group_concat(Column#6 order by Column#7 desc separator \"++\")->Column#4, funcs:group_concat(Column#8 order by Column#7 desc, Column#9 separator \"--\")->Column#5",
"└─Projection 10000.00 root cast(test.test.name, var_string(20))->Column#6, test.test.name->Column#7, cast(test.test.id, var_string(20))->Column#8, test.test.id->Column#9",
" └─TableReader 10000.00 root data:TableFullScan",
" └─TableFullScan 10000.00 cop[tikv] table:test keep order:false, stats:pseudo"
],
Expand All @@ -2606,8 +2606,8 @@
{
"SQL": "select /*+ agg_to_cop */ group_concat(name ORDER BY name desc SEPARATOR '++'), group_concat(id ORDER BY name desc, id asc SEPARATOR '--') from ptest;",
"Plan": [
"HashAgg 1.00 root funcs:group_concat(Column#6 order by Column#7 desc separator \"++\")->Column#4, funcs:group_concat(Column#8 order by Column#9 desc, Column#10 separator \"--\")->Column#5",
"└─Projection 10000.00 root cast(test.ptest.name, var_string(20))->Column#6, test.ptest.name->Column#7, cast(test.ptest.id, var_string(20))->Column#8, test.ptest.name->Column#9, test.ptest.id->Column#10",
"HashAgg 1.00 root funcs:group_concat(Column#6 order by Column#7 desc separator \"++\")->Column#4, funcs:group_concat(Column#8 order by Column#7 desc, Column#9 separator \"--\")->Column#5",
"└─Projection 10000.00 root cast(test.ptest.name, var_string(20))->Column#6, test.ptest.name->Column#7, cast(test.ptest.id, var_string(20))->Column#8, test.ptest.id->Column#9",
" └─TableReader 10000.00 root partition:all data:TableFullScan",
" └─TableFullScan 10000.00 cop[tikv] table:ptest keep order:false, stats:pseudo"
],
Expand Down Expand Up @@ -3597,15 +3597,15 @@
"TopN 20.00 root Column#10, offset:0, count:20",
"└─HashAgg 63.95 root group by:test.tbl_16.col_100, funcs:avg(Column#11, Column#12)->Column#10",
" └─PartitionUnion 63.95 root ",
" ├─StreamAgg 31.98 root group by:Column#22, funcs:count(Column#19)->Column#11, funcs:sum(Column#20)->Column#12, funcs:firstrow(Column#21)->test.tbl_16.col_100",
" │ └─Projection 39.97 root test.tbl_16.col_100->Column#19, cast(test.tbl_16.col_100, decimal(8,0) UNSIGNED BINARY)->Column#20, test.tbl_16.col_100->Column#21, test.tbl_16.col_100->Column#22",
" ├─StreamAgg 31.98 root group by:Column#19, funcs:count(Column#19)->Column#11, funcs:sum(Column#20)->Column#12, funcs:firstrow(Column#21)->test.tbl_16.col_100",
" │ └─Projection 39.97 root test.tbl_16.col_100->Column#19, cast(test.tbl_16.col_100, decimal(8,0) UNSIGNED BINARY)->Column#20, test.tbl_16.col_100->Column#21",
" │ └─Sort 39.97 root test.tbl_16.col_100",
" │ └─TableReader 39.97 root MppVersion: 2, data:ExchangeSender",
" │ └─ExchangeSender 39.97 mpp[tiflash] ExchangeType: PassThrough",
" │ └─Selection 39.97 mpp[tiflash] or(eq(test.tbl_16.col_100, 10672141), in(test.tbl_16.col_104, \"yfEG1t!*b\", \"C1*bqx_qyO\", \"vQ^yUpKHr&j#~\"))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:tbl_16, partition:p0 pushed down filter:empty, keep order:false, stats:pseudo",
" └─StreamAgg 31.98 root group by:Column#26, funcs:count(Column#23)->Column#11, funcs:sum(Column#24)->Column#12, funcs:firstrow(Column#25)->test.tbl_16.col_100",
" └─Projection 39.97 root test.tbl_16.col_100->Column#23, cast(test.tbl_16.col_100, decimal(8,0) UNSIGNED BINARY)->Column#24, test.tbl_16.col_100->Column#25, test.tbl_16.col_100->Column#26",
" └─StreamAgg 31.98 root group by:Column#22, funcs:count(Column#22)->Column#11, funcs:sum(Column#23)->Column#12, funcs:firstrow(Column#24)->test.tbl_16.col_100",
" └─Projection 39.97 root test.tbl_16.col_100->Column#22, cast(test.tbl_16.col_100, decimal(8,0) UNSIGNED BINARY)->Column#23, test.tbl_16.col_100->Column#24",
" └─Sort 39.97 root test.tbl_16.col_100",
" └─TableReader 39.97 root MppVersion: 2, data:ExchangeSender",
" └─ExchangeSender 39.97 mpp[tiflash] ExchangeType: PassThrough",
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/issuetest/planner_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func Test53726(t *testing.T) {
Check(testkit.Rows("-258025139 -258025139", "575932053 575932053"))
tk.MustQuery("explain select distinct cast(c as decimal), cast(c as signed) from t7").
Check(testkit.Rows(
"HashAgg_6 2.00 root group by:Column#13, Column#14, funcs:firstrow(Column#11)->Column#3, funcs:firstrow(Column#12)->Column#4",
"└─Projection_12 2.00 root cast(test.t7.c, decimal(10,0) BINARY)->Column#11, cast(test.t7.c, bigint(22) BINARY)->Column#12, cast(test.t7.c, decimal(10,0) BINARY)->Column#13, cast(test.t7.c, bigint(22) BINARY)->Column#14",
"HashAgg_6 2.00 root group by:Column#11, Column#12, funcs:firstrow(Column#11)->Column#3, funcs:firstrow(Column#12)->Column#4",
"└─Projection_12 2.00 root cast(test.t7.c, decimal(10,0) BINARY)->Column#11, cast(test.t7.c, bigint(22) BINARY)->Column#12",
" └─TableReader_11 2.00 root data:TableFullScan_10",
" └─TableFullScan_10 2.00 cop[tikv] table:t7 keep order:false"))
}
Loading