Hive内置了很多函数,方便实现对数据的操作。这次我们来看下其中的数学函数。
函数的具体使用,如下所示。
1、round(double a)
hive (default)> select round(2.3);
OK
_c0
2.0
Time taken: 0.081 seconds, Fetched: 1 row(s)
说明:对2.3进行四舍五入,结果为2.0
hive (default)> select round(2.6);
OK
_c0
3.0
Time taken: 0.063 seconds, Fetched: 1 row(s)
说明:对2.6进行四舍五入,结果为3.0
2、round(double a, int d)
hive (default)> select round(5.683,2);
OK
_c0
5.68
Time taken: 0.862 seconds, Fetched: 1 row(s)
说明:对5.683保留两位小数,对3进行四舍五入
hive (default)> select round(5.689,2);
OK
_c0
5.69
Time taken: 0.073 seconds, Fetched: 1 row(s)
说明:对5.689保留两位小数,对9进行四舍五入
3、floor(double a)
<