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