Are timestamps stored with a timezone in Apache Hi

2019-07-11 03:33发布

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条回答
放我归山
2楼-- · 2019-07-11 03:56

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

查看更多
登录 后发表回答