Are timestamps stored with a timezone in Apache Hive?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 18:15:53

问题


The following discussion seems to indicate that Hive timestamps have a timezone: https://community.hortonworks.com/questions/83523/timestamp-in-hive-without-timezone.html

The apache wiki says "Timestamps are interpreted to be timezoneless and stored as an offset from the UNIX epoch."

I am referring to: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-TimestampstimestampTimestamps

If I use code like the following:

from_unixtime(unix_timestamp(ts_field,'yyyy-MM-dd HH:mm:ss'), 'yyyy-MM-dd HH:mm:ss z') as ts_field_tz

This seems to expose an underlying timezone value.


回答1:


The phrase "timezone-less" is misleading; what it means actually is that...

If you have data files written by Hive, those TIMESTAMP values represent the local timezone of the host where the data was written

That is an excerpt from the Impala documentation -- and they make it very explicit, because it's a real pain when you need to access the same table from both Hive and Impala, since contrary to Hive...

By default, Impala does not store timestamps using the local timezone, to avoid undesired results from unexpected time zone issues. Timestamps are stored and interpreted relative to UTC



来源:https://stackoverflow.com/questions/44647134/are-timestamps-stored-with-a-timezone-in-apache-hive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!