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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to