首页 > 试题广场 >

Hive中两大表连接,发生了数据倾斜,有一个reduce无法

[问答题]
Hive中两大表连接,发生了数据倾斜,有一个reduce无法完成,检查发现t1中guid=''的记录有很多,其他guid都不重复,这条语句该怎样优化?
select t1.*
,nvl(t2.x,1)
from t1
left join t2
on t1.guid = t2.guid

对guid字段中的空串加随机数,打散到其他的reducer中,避免这个reducer的压力太大
select t1.*, nvl(t2.x,1)
from t1
left join t2
on (case when t1.guid='' then concat('yuewen', rand()) else t1.guid end)=t2.guid;


编辑于 2021-01-14 10:46:38 回复(0)
select t1.*,nvl(t2.x,1)
from t1
left join t2
on (case when t1.guid=' ' then concat('yuewen',rand()) else t1.guid end)=t2.guid;
发表于 2021-01-23 21:39:20 回复(0)