ashish-kumar-sharma commented on a change in pull request #2590:
URL: https://github.com/apache/hive/pull/2590#discussion_r692794697



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

Review comment:
       Done




-- 
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