无法使用 Hue 编辑器在 Hive 查询中获得 2 个小数位

Not able to get 2 decimal places in Hive query using Hue editor

我正在 Cloudera VM 的 Hue 编辑器中编写 Hive 查询。但不知何故,我没有得到小数点后两位的数据。如果我 运行 在 shell 上使用相同的代码,它会给出正确的结果。我正在使用最新的 cloudera 版本。

select u.column1, r.column2, AVG(round(r.metric,2)) as avgr from table1 r, table2 u where u.userid= r.userid and r.metric is not null group by u.column1, r.column2;

round()returnsdoubleAVG()也returnsdouble

最好在 AVG 之后申请:

 round(AVG(r.metric),2)

如果GUI仍然显示不正确,请显式转换为decimal

cast(round(AVG(r.metric),2) as decimal(19,2))