我有以下记录集要处理
1000, 1001, 1002 to 1999,
2000, 2001, 2002 to 2999,
3000, 3001, 3002 to 3999
我想使用HIVE处理以下记录集,以便reducer-1将处理1000至1999的数据,reduce-2将处理2000至2999的数据,reducer-3将处理3000至3999的数据。请帮助我解决以上问题。
最佳答案
使用DISTRIBUTE BY
,映射器的输出将根据distribution by子句进行分组,以传输到reduce进行处理:
select ...
from ...
distribute by case when col between 1000 and 1999 then 1
when col between 2000 and 2999 then 2
when col between 3000 and 3999 then 3
end
或者简单地
distribute by floor(col/1000)
关于hadoop - hive 中的 reducer 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59882425/