Hive常⽤函数⼤全-数值计算 11、取整函数:round(X)(遵循四舍五⼊)
2select round(3.1415926) from table--3
3select round(3.5) from table--4
4
52、指定精度取整函数: round(X,Y)(遵循四舍五⼊)
6select round(3.14159,3) from table--3.142
7select round(3.14123,3) from table--3.141
8
93、向下取整函数: floor(X)
10select floor(3.6) from table--3
11select floor(3.3) from table--3
hue trunc函数
12
134、向上取整函数: ceiling(X)
14select ceiling(3.6) from table--4
15select ceiling(3.3) from table--4
16
175、取随机数函数: rand(X)(返回⼀个0到1范围内的随机数)
18select rand() from table--0.222121323242
19
206、取随机数函数: rand(X)(重复执⾏结果相同:返回⼀个稳定的随机数序列)
21select rand(100) from table--0.6841454782373
22
237、⾃然指数函数: exp(X)(返回e的X次⽅)
24select exp(2) from table--e*e
25
268、以10为底对数函数: log10(X)(返回以10为底的X的对数)
27select log10(100) from table--2
28
299、以2为底对数函数: log2(X)(返回以2为底的X的对数)
30select log2(8) from table--3
31
3210、对数函数: log(X,Y)(返回以X为底的y的对数:2的3次⽅=8)
33select log(2,8) from table--3
34
3511、幂运算函数: pow(X,Y)/power(X,Y)(返回X的Y次幂)
36select pow(2,4) from table--16
37
3812、开平⽅函数: sqrt(X)(返回X的平⽅根)
39select sqrt(16) from table--4
40
4113、⼆进制函数: bin(X)(返回X的⼆进制表⽰)
42select bin(7) from table--111
43
4414、⼗六进制函数: hex(X)(返回X的⼗六进制表⽰)
45select hex('ab') from table--6162
46
4715、反转⼗六进制函数: unhex(X)
48select hex('6162') from table--ab
49
5016、进制转换函数: conv(X,Y,Z)(将数值X从Y进制转化到Z进制)
51select conv(17,10,2) from table--10001
52
5317、绝对值函数: abs(X)(返回X的绝对值)
54select abs(-111.9) from table--111.9
55select abs(111.9) from table--111.9
56
5718、正取余函数: pmod(X,Y)(返回X除以Y的余数)
58select pmod(9,4) from table--1
59select pmod(-9,4) from table--3
60
6119、正弦函数: sin(X)(返回X的正弦值)
62select sin(0.8) from table--0.7173560908995228
63
6420、反正弦函数: asin(X)(返回X的反正弦值)
65select asin(0.7173560908995228) from table--0.8
66
6721、余弦函数: cos(X)(返回X的余弦值)
68select cos(0.9) from table--0.6216099682706644
69
7022、反余弦函数: acos(X)(返回X的反余弦值)
71select cos(0.6216099682706644) from table--0.9

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。