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

Bharathkrishna Guruvayoor Murali commented on HIVE-19354:
---------------------------------------------------------

 

These are the outputs expected after the changes in this patch:
{code:java}

0: jdbc:hive2://localhost:10000/default> select from_utc_timestamp('2000-10-10 
00:00:00', 'America/Los_Angeles');

[..]

+------------------------+
| _c0 |
+------------------------+
| 2000-10-09 17:00:00.0 |
+------------------------+
1 row selected (0.25 seconds)

0: jdbc:hive2://localhost:10000/default> select from_utc_timestamp('2000-10-10 
00:00:00+00:00', 'America/Los_Angeles');

[..]

+------------------------+
| _c0 |
+------------------------+
| 2000-10-09 17:00:00.0 |
+------------------------+
1 row selected (0.106 seconds)

0: jdbc:hive2://localhost:10000/default> select from_utc_timestamp('2000-10-10 
00:00:00+03:00', 'America/Los_Angeles');

[..]

+------------------------+
| _c0 |
+------------------------+
| 2000-10-09 14:00:00.0 |
+------------------------+
1 row selected (0.11 seconds)


{code}
Observe that output of 1st and 2nd query are the same.

 

 

For the 3rd query, it is interpreted as :

 2000-10-10 00:00:00+03:00 in UTC is 2000-10-09 21:00 (because our input is 
expected to be in UTC , hence +03:00 means utc plus 3 hours).

Hence, when we convert it to America/Los_Angeles timezone( which is UTC - 7), 
it will be 2000-10-09 14:00:00.0 

 

> from_utc_timestamp returns incorrect results for datetime values with timezone
> ------------------------------------------------------------------------------
>
>                 Key: HIVE-19354
>                 URL: https://issues.apache.org/jira/browse/HIVE-19354
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive
>    Affects Versions: 3.1.0
>            Reporter: Bruce Robbins
>            Assignee: Bharathkrishna Guruvayoor Murali
>            Priority: Major
>         Attachments: HIVE-19354.01.patch
>
>
> On the master branch, from_utc_timestamp returns incorrect results for 
> datetime strings that contain a timezone:
> {noformat}
> hive> select from_utc_timestamp('2000-10-10 00:00:00+00:00', 
> 'America/Los_Angeles');
> OK
> 2000-10-09 10:00:00
> Time taken: 0.294 seconds, Fetched: 1 row(s)
> hive> select from_utc_timestamp('2000-10-10 00:00:00', 'America/Los_Angeles');
> OK
> 2000-10-09 17:00:00
> Time taken: 0.121 seconds, Fetched: 1 row(s)
> hive> 
> {noformat}
> Both inputs are 2000-10-10 00:00:00 in UTC time, but I got two different 
> results.
> In version 2.3.3, from_utc_timestamp doesn't accept timezones in its input 
> strings, so it does not have this bug:
> {noformat}
> hive> select from_utc_timestamp('2000-10-10 00:00:00+00:00', 
> 'America/Los_Angeles');
> OK
> NULL
> Time taken: 5.152 seconds, Fetched: 1 row(s)
> hive> select from_utc_timestamp('2000-10-10 00:00:00', 'America/Los_Angeles');
> OK
> 2000-10-09 17:00:00
> Time taken: 0.069 seconds, Fetched: 1 row(s)
> hive> 
> {noformat}
> Since the function is expecting a UTC datetime value, it probably should 
> continue to reject input that contains a timezone component.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to