Thursday 12 February 2015

Default Timezone for from_unixtime() in Hive

from_unixtime(unixtime, format) in Hive doesn't provide a timezone option.
Instead, it assumes all unixtime stored in Hive is in Hive server's system timezone.
So from_unixtime() will return the Hive server timezone.

To verify this,  SELECT from_unixtime(0) t0 FROM table;

If it’s UTC, the return should be 1970-01-01 00:00:00, but the result will depend on your hive server timezone.


Below is a UDF can accept user defined timezone.

Reference:
https://github.com/nitinpawar/hive-udfs/tree/master/FromUnixtimeWithTZ
http://mail-archives.apache.org/mod_mbox/hive-user/201411.mbox/%3C4B345C5B-64B3-4459-B4DB-5F2DBB73285A@hortonworks.com%3E

No comments:

Post a Comment