【Hive】Hive3中trunc函数功能

本文介绍了在Hive3.1.1版本中trunc函数新增的特性,特别是在处理时间到季度首月的能力上,展示了如何利用trunc('2017-03-15', 'Q')来获取时间的季度首月,说明了Hive3相对于Hive2的改进和增强。" 133509346,20036685,Oracle 12c Release 2中的MySQL服务配置与使用,"['数据库', 'Oracle', 'MySQL', '安装教程', 'Python连接']
摘要由CSDN通过智能技术生成

Hive3中trunc函数功能

场景:
因工作上使用的是hive2版本,并且在业务中需要用到trunc函数获取时间的季度的第一个月份,
但查询hive2版本并没有像oracle那样的获取季度的时间。

因hive已更新到hive3版本,想了解是否在新的版本里的trunc函数是否添加了各更多的功能,
于是在伪分布式hadoop里安装了hive3.1.1版本,然后查看trunc相关使用方法

hive (default)> desc function extended trunc;
OK
tab_name
trunc(date, fmt) / trunc(N,D) - Returns If input is date returns date with the time portion of the day truncated to the unit specified by the format model fmt. If you omit fmt, then date is truncated to the nearest day. It currently only supports 'MONTH'/'MON'/'MM', 'QUARTER'/'Q' and 'YEAR'/'YYYY'/'YY' as format.If input is a number group returns N truncated to D decimal places. If D is omitted, then N is truncated to 0 places.D can be negative to truncate (make zero) D digit
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值