[ https://issues.apache.org/jira/browse/HIVE-25458?focusedWorklogId=640172&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-640172 ]
ASF GitHub Bot logged work on HIVE-25458: ----------------------------------------- Author: ASF GitHub Bot Created on: 20/Aug/21 09:10 Start Date: 20/Aug/21 09:10 Worklog Time Spent: 10m Work Description: 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 640172) Time Spent: 1h (was: 50m) > unix_timestamp() with string input give 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: 1h > Remaining Estimate: 0h > > Description - > unix_timestamp() accept 4 value string/date/timestamp/timestamptz. Out of > which date/timestamp/timestamptz use DateTimeFormatter.class where as string > type use SimpleDateTimeformatter.class which cause difference is value. > Example - > select from_unixtime(unix_timestamp('1800-11-08 01:53:11')); > 1800-11-08 01:35:15 > select from_unixtime(unix_timestamp(cast('1800-11-08 01:53:11' as > timestamp))); > 1800-11-08 01:53:11 > -- This message was sent by Atlassian Jira (v8.3.4#803005)