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

Rui Li commented on HIVE-14412:
-------------------------------

The latest failure are not related.

[~cartershanklin], the Postgres example you mentioned can be achieved with v12 
patch. But since Hive currently doesn't support session zone, user has to 
change system zone to do that. I also added a test case for it:
{code}
  @Test
  public void testConvertFromTimestamp() {
    TimeZone defaultZone = TimeZone.getDefault();
    try {
      // Use system zone when converting from timestamp to timestamptz
      String s = "2017-06-12 23:12:56.34";
      TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
      TimestampTZ tstz1 = TimestampTZ.convert(Timestamp.valueOf(s));
      TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
      TimestampTZ tstz2 = TimestampTZ.convert(Timestamp.valueOf(s));
      Assert.assertTrue(tstz1.compareTo(tstz2) < 0);
    } finally {
      TimeZone.setDefault(defaultZone);
    }
  }
{code}
What I was trying to say is, by converting to a target timezone, users usually 
expect to see the timestamp displayed in that timezone. E.g. if users want to 
convert '2012-01-01 08:00:00+00' to PST8PDT, they should be expecting 
'2012-01-01 00:00:00-08' right? But w/o storing the zone, all timestamptz 
display in UTC. Session zone doesn't seem to help because the target zone isn't 
necessarily same as session zone.

> 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