Hive SQL函数整理

本文整理了Hive SQL中的关系、日期、条件、数字、字符串、统计、行转列和列转行等常用函数,涵盖了从基本操作到复杂转换的各种场景,帮助你更好地理解和运用Hive SQL。
摘要由CSDN通过智能技术生成

hive sql跟mysql还是有点区别的。这里整理下一些自己常用的函数。

一、关系函数

匹配某列是否等于某值或列,比如A <> B。

关系函数
函数 语法及含义 注意及举例
= 等值比较 不要用于NULL
<> 不等 不要用于NULL
< 小于 不要用于NULL
<= 小于等于 不要用于NULL
> 大于 不要用于NULL
>= 大于等于 不要用于NULL
IS NULL 空值判断
IS NOT NULL 非空判断
LIKE 也可以 NOT LIKE 不要用于NULL
RLIKE/REGEXP 正则匹配 不要用于NULL

二、日期函数

Hive设置大量的日期处理

函数

含义

语法

返回结果例子

current_date

当前日期

current_date()

2019-07-31

current_timestamp

当前时间,到秒

current_timestamp()

2019-07-31 21:48:59.906

from_unixtime

时间戳转日期字符串

from_unixtime(bigint unixtime[, string format])

unix_timestamp

获取当前unix时间戳

unix_timestamp()

1564580955

unix_timestamp

字符串时间转时间戳

unix_timestamp(string date)

"yyyy-MM-dd HH:mm:ss”格式

unix_timestamp

字符串时间转时间戳

unix_timestamp(string date, string pattern)

to_date

返回日期时间字段中的日期部分

to_date(string timestamp)

year

日期中的年

year(string date)

month

日期中的月

month(string date)

day

日期中的天

day (string date)

hour

日期中的小时

hour (string date)

minute

日期中的分钟

minute (string date)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值