[ 
https://issues.apache.org/jira/browse/HIVE-25458?focusedWorklogId=638621&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-638621
 ]

ASF GitHub Bot logged work on HIVE-25458:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Aug/21 11:43
            Start Date: 17/Aug/21 11:43
    Worklog Time Spent: 10m 
      Work Description: adesh-rao commented on a change in pull request #2590:
URL: https://github.com/apache/hive/pull/2590#discussion_r690288067



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFToUnixTimeStamp.java
##########
@@ -164,15 +164,13 @@ public Object evaluate(DeferredObject[] arguments) throws 
HiveException {
           return null;
         }
         if (!patternVal.equals(lasPattern)) {
-          formatter.applyPattern(patternVal);
+          formatter = DateTimeFormatter.ofPattern(patternVal);
           lasPattern = patternVal;
         }
       }
-      try {
-        retValue.set(formatter.parse(textVal).getTime() / 1000);
-      } catch (ParseException e) {
-        return null;
-      }
+      Timestamp timestamp = new 
Timestamp(LocalDateTime.parse(textVal,formatter));

Review comment:
       nit: spaces after comma

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFToUnixTimeStamp.java
##########
@@ -20,10 +20,14 @@
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;

Review comment:
       nit: remove unused imports

##########
File path: ql/src/test/queries/clientpositive/udf5.q
##########
@@ -45,3 +45,10 @@ select from_unixtime(to_unix_timestamp(cast('0000-00-00' as 
date)));
 set time zone Europe/Rome;
 
 SELECT from_unixtime(1226446340), to_date(from_unixtime(1226446340)), 
day('2008-11-01'), month('2008-11-01'), year('2008-11-01'), day('2008-11-01 
15:32:20'), month('2008-11-01 15:32:20'), year('2008-11-01 15:32:20') FROM 
dest1_n14;
+
+set hive.local.time.zone=Asia/Bangkok;
+
+select from_unixtime(unix_timestamp('1400-11-08 01:53:11'));
+select from_unixtime(unix_timestamp('1800-11-08 01:53:11'));
+select from_unixtime(unix_timestamp('1400-11-08 08:00:00 ICT', 'yyyy-MM-dd 
HH:mm:ss z'));

Review comment:
       Can we add a test for a different timezone too? both asia/Bangkok and 
ICT are GMT +7




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 638621)
    Time Spent: 20m  (was: 10m)

> Combination of from_unixtime() and unix_timestamp() is giving wrong result
> --------------------------------------------------------------------------
>
>                 Key: HIVE-25458
>                 URL: https://issues.apache.org/jira/browse/HIVE-25458
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Description - 
> set hive.local.time.zone=Asia/Bangkok;
> select from_unixtime(unix_timestamp('1400-11-08 01:53:11'));
> Result - 1400-11-17 01:35:15
> Expected - 1400-11-08 01:53:11
> select from_unixtime(unix_timestamp('1800-11-08 01:53:11'));
> Result - 1800-11-08 01:35:15
> Expected - 1800-11-08 01:53:11
> select from_unixtime(unix_timestamp('1400-11-08 08:00:00 ICT', 'yyyy-MM-dd 
> HH:mm:ss z'));
> Result 1400-11-17 07:42:04
> Expected 1400-11-08 08:00:00 
> select from_unixtime(unix_timestamp('1800-11-08 08:00:00 ICT', 'yyyy-MM-dd 
> HH:mm:ss z'));
> Result - 1800-11-08 07:42:04
> Expected - 1800-11-08 08:00:00 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to