尝试在hive CLI中运行简单查询 -
select to_utc_timestamp(unix_timestamp("04/24/2017 01:59:01","MM/dd/YYYY HH:mm:ss"),'EST');
结果:
OK
1970-01-18 09:00:35.941
Time taken: 0.448 seconds, Fetched: 1 row(s)
输出不应该只是日期加4小时吗?
答案 0 :(得分:1)
yyyy
(而不是YYYY
)unix_timestamp
返回bigint,to_utc_timestamp
将整数值视为毫秒select to_utc_timestamp(1000*unix_timestamp("04/24/2017 01:59:01","MM/dd/yyyy HH:mm:ss"),'EST');
答案 1 :(得分:0)
我们走了。您需要将unix_timestamp
包裹在from_unixtime
。
select to_utc_timestamp(from_unixtime(unix_timestamp('04/24/2017 01:59:01','MM/dd/yyyy hh:mm:ss'),'yyyy-MM-dd hh:mm:ss'),"EST");