presto from_unixtime 函数对吗?
presto from_unixtime function is right?
我查询关于 bigint 的时间戳,值是“1494257400”
我将使用 presto 查询
但是 presto 没有收集关于 from_unixtime() 函数的结果。
配置单元版本。
select from_unixtime(1494257400) result : '2017-05-09 00:30:00'
presto 版本。
块引用
select from_unixtime(1494257400) result : '2017-05-08 08:30:00'
hive给出了一个collect结果,但是转眼就不是collect结果。我该如何解决呢?
转眼间 from_unixtime
returns 你在 UTC 约会,而 Hive returns 你在当地时区约会。
根据https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF,from_unixtime
:
Converts the number of seconds from unix epoch (1970-01-01 00:00:00
UTC) to a string representing the timestamp of that moment in the
current system time zone in the format of "1970-01-01 00:00:00".
Hive 的输出不是很好,因为 ISO 格式的字符串应该显示 GMT 数据,如果它们有任何不是 GMT+00 的数据。
使用 Hive,您可以使用 to_utc_timestamp({any primitive type} ts, string timezone)
将时间戳转换为正确的时区。看一下上面提供的link的手册
我查询关于 bigint 的时间戳,值是“1494257400”
我将使用 presto 查询 但是 presto 没有收集关于 from_unixtime() 函数的结果。
配置单元版本。
select from_unixtime(1494257400) result : '2017-05-09 00:30:00'
presto 版本。
块引用
select from_unixtime(1494257400) result : '2017-05-08 08:30:00'
hive给出了一个collect结果,但是转眼就不是collect结果。我该如何解决呢?
转眼间 from_unixtime
returns 你在 UTC 约会,而 Hive returns 你在当地时区约会。
根据https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF,from_unixtime
:
Converts the number of seconds from unix epoch (1970-01-01 00:00:00 UTC) to a string representing the timestamp of that moment in the current system time zone in the format of "1970-01-01 00:00:00".
Hive 的输出不是很好,因为 ISO 格式的字符串应该显示 GMT 数据,如果它们有任何不是 GMT+00 的数据。
使用 Hive,您可以使用 to_utc_timestamp({any primitive type} ts, string timezone)
将时间戳转换为正确的时区。看一下上面提供的link的手册