Skip to content

Commit b6e5281

Browse files
authored
[Fix](bug) fix the divide zero in local shuffle: (#37948)
## Proposed changes cherry pick #37906 <!--Describe your changes.-->
1 parent 21c6b85 commit b6e5281

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

be/src/pipeline/pipeline_x/pipeline_x_fragment_context.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,12 @@ Status PipelineXFragmentContext::_plan_local_exchange(
298298
}
299299
}
300300

301+
// if 'num_buckets == 0' means the fragment is colocated by exchange node not the
302+
// scan node. so here use `_num_instance` to replace the `num_buckets` to prevent dividing 0
303+
// still keep colocate plan after local shuffle
301304
RETURN_IF_ERROR(_plan_local_exchange(
302-
_pipelines[pip_idx]->operator_xs().front()->ignore_data_hash_distribution()
305+
_pipelines[pip_idx]->operator_xs().front()->ignore_data_hash_distribution() ||
306+
num_buckets == 0
303307
? _num_instances
304308
: num_buckets,
305309
pip_idx, _pipelines[pip_idx], bucket_seq_to_instance_idx,
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !withGroupByUnion --
3+
0 ALGERIA
4+
1 ALGERIA
5+
1 ARGENTINA
6+
1 BRAZIL
7+
1 CANADA
8+
1 CHINA
9+
1 EGYPT
10+
1 ETHIOPIA
11+
1 FRANCE
12+
1 GERMANY
13+
1 INDIA
14+
1 INDONESIA
15+
1 IRAN
16+
1 IRAQ
17+
1 JAPAN
18+
1 JORDAN
19+
1 KENYA
20+
1 MOROCCO
21+
1 MOZAMBIQUE
22+
1 PERU
23+
1 ROMANIA
24+
1 RUSSIA
25+
1 SAUDI ARABIA
26+
1 UNITED KINGDOM
27+
1 UNITED STATES
28+
1 VIETNAM
29+
2 BRAZIL
30+
3 CANADA
31+
4 EGYPT
32+
5 ETHIOPIA
33+
6 FRANCE
34+
7 GERMANY
35+
8 INDIA
36+
9 INDONESIA
37+
10 IRAN
38+
11 IRAQ
39+
12 JAPAN
40+
13 JORDAN
41+
14 KENYA
42+
15 MOROCCO
43+
16 MOZAMBIQUE
44+
17 PERU
45+
18 CHINA
46+
19 ROMANIA
47+
20 SAUDI ARABIA
48+
21 VIETNAM
49+
22 RUSSIA
50+
23 UNITED KINGDOM
51+
24 UNITED STATES
52+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from (select count(a.nationkey), a.name from tpch_tiny_nation a join[shuffle] tpch_tiny_nation b on a.name = b.name group by a.name union select sum(c.nationkey), c.name from tpch_tiny_nation c join[shuffle] tpch_tiny_nation d on c.name = d.name group by c.name) t order by 1,2 limit 50;

0 commit comments

Comments
 (0)