[ 
https://issues.apache.org/jira/browse/HIVE-14412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16001774#comment-16001774
 ] 

Carter Shanklin commented on HIVE-14412:
----------------------------------------

You can store the time zone or adjust the values based on the session time zone.

Consider this Postgres example:
{code}
vagrant=# set time zone 'GMT';
SET
vagrant=# create table test (c1 timestamp with time zone);
CREATE TABLE
vagrant=# insert into test values (date '2012-01-01');
INSERT 0 1
vagrant=# set time zone 'PST8PDT';
SET
vagrant=# insert into test values (date '2012-01-01');
INSERT 0 1
vagrant=# set time zone 'GMT';
SET
vagrant=# select * from test;
           c1
------------------------
 2012-01-01 00:00:00+00
 2012-01-01 08:00:00+00
(2 rows)
{code}

Yet Postgres is not actually storing the time zone, it tries to be clever and 
automatically adjust based on your session time zone (and works most of the 
time), e.g.:

{code}
vagrant=# set time zone 'GMT';
SET
vagrant=# select extract(timezone from c1) from test;
 date_part
-----------
         0
         0
(2 rows)

vagrant=# set time zone 'PST8PDT';
SET
vagrant=# select extract(timezone from c1) from test;
 date_part
-----------
    -28800
    -28800
(2 rows)
{code}

Essentially saying that everything is in GMT internally but the session time 
zone adjust things so the developer doesn't think about it.

> Add a timezone-aware timestamp
> ------------------------------
>
>                 Key: HIVE-14412
>                 URL: https://issues.apache.org/jira/browse/HIVE-14412
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Hive
>            Reporter: Rui Li
>            Assignee: Rui Li
>         Attachments: HIVE-14412.10.patch, HIVE-14412.11.patch, 
> HIVE-14412.12.patch, HIVE-14412.1.patch, HIVE-14412.2.patch, 
> HIVE-14412.3.patch, HIVE-14412.4.patch, HIVE-14412.5.patch, 
> HIVE-14412.6.patch, HIVE-14412.7.patch, HIVE-14412.8.patch, HIVE-14412.9.patch
>
>
> Java's Timestamp stores the time elapsed since the epoch. While it's by 
> itself unambiguous, ambiguity comes when we parse a string into timestamp, or 
> convert a timestamp to string, causing problems like HIVE-14305.
> To solve the issue, I think we should make timestamp aware of timezone.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to