hive 中的函数自总
- cast() ;类型转换
cast(date as date)
cast(timestamp as date)
cast(string as date):如果string是YYYY-MM-DD格式的,则相应的年/月/日的date类型的数据将会返回;但如果string不是YYYY-MM-DD格式的,结果则会返回NULL。
cast(date as timestamp):基于当地的时区,生成一个对应date的年/月/日的时间戳值
cast(date as string):date所代表的年/月/日时间将会转换成YYYY-MM-DD的字符串
select cast(1 as float); --1.0
select cast(‘2016-05-22’ as date); --2016-05-22
后续补充