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

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

                Author: ASF GitHub Bot
            Created on: 23/Jun/21 15:53
            Start Date: 23/Jun/21 15:53
    Worklog Time Spent: 10m 
      Work Description: guptanikhil007 commented on a change in pull request 
#2409:
URL: https://github.com/apache/hive/pull/2409#discussion_r657244949



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateFormat.java
##########
@@ -74,30 +72,28 @@ public ObjectInspector initialize(ObjectInspector[] 
arguments) throws UDFArgumen
     // the function should support both short date and full timestamp format
     // time part of the timestamp should not be skipped
     checkArgGroups(arguments, 0, tsInputTypes, STRING_GROUP, DATE_GROUP);
-    checkArgGroups(arguments, 0, dtInputTypes, STRING_GROUP, DATE_GROUP);
-
     checkArgGroups(arguments, 1, tsInputTypes, STRING_GROUP);
 
     obtainTimestampConverter(arguments, 0, tsInputTypes, tsConverters);
-    obtainDateConverter(arguments, 0, dtInputTypes, dtConverters);
 
     if (arguments[1] instanceof ConstantObjectInspector) {
       String fmtStr = getConstantStringValue(arguments, 1);
       if (fmtStr != null) {
         try {
-          formatter = new SimpleDateFormat(fmtStr);
-          
formatter.setCalendar(DateTimeMath.getTimeZonedProlepticGregorianCalendar());
+          if (timeZone == null) {
+            timeZone = SessionState.get() == null ? new 
HiveConf().getLocalTimeZone() : SessionState.get().getConf()
+                .getLocalTimeZone();
+          }
+          formatter = DateTimeFormatter.ofPattern(fmtStr).withZone(timeZone);
         } catch (IllegalArgumentException e) {

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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 614093)
    Time Spent: 7h 20m  (was: 7h 10m)

> date_format udf doesn't work for dates prior to 1900 if the timezone is 
> different from UTC
> ------------------------------------------------------------------------------------------
>
>                 Key: HIVE-25268
>                 URL: https://issues.apache.org/jira/browse/HIVE-25268
>             Project: Hive
>          Issue Type: Bug
>          Components: UDF
>    Affects Versions: 3.1.0, 3.1.1, 3.1.2, 4.0.0
>            Reporter: Nikhil Gupta
>            Assignee: Nikhil Gupta
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 7h 20m
>  Remaining Estimate: 0h
>
> *Hive 1.2.1*:
> {code:java}
>  select date_format('1400-01-14 01:00:00', 'yyyy-MM-dd HH:mm:ss z');
> +--------------------------+--+
> |           _c0            |
> +--------------------------+--+
> | 1400-01-14 01:00:00 ICT  |
> +--------------------------+--+
> select date_format('1800-01-14 01:00:00', 'yyyy-MM-dd HH:mm:ss z');
> +--------------------------+--+
> |           _c0            |
> +--------------------------+--+
> | 1800-01-14 01:00:00 ICT  |
> +--------------------------+--+
> {code}
> *Hive 3.1, Hive 4.0:*
> {code:java}
> select date_format('1400-01-14 01:00:00', 'yyyy-MM-dd HH:mm:ss z');
> +--------------------------+
> |           _c0            |
> +--------------------------+
> | 1400-01-06 01:17:56 ICT  |
> +--------------------------+
> select date_format('1800-01-14 01:00:00', 'yyyy-MM-dd HH:mm:ss z');
> +--------------------------+
> |           _c0            |
> +--------------------------+
> | 1800-01-14 01:17:56 ICT  |
> +--------------------------+
> {code}
> VM timezone is set to 'Asia/Bangkok'



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

Reply via email to