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

问题描述 投票:1回答:1

我正在Cloudera VM的Hue编辑器中编写Hive查询。但不知何故,我没有得到2位小数的数据。如果我在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;

enter image description here

hive hue
1个回答
1
投票

round()返回doubleAVG()也返回double

AVG之后更好地应用:

 round(AVG(r.metric),2)

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

cast(round(AVG(r.metric),2) as decimal(19,2)) 
© www.soinside.com 2019 - 2024. All rights reserved.