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

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

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



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateFormat.java
##########
@@ -51,18 +50,17 @@
  */
 @Description(name = "date_format", value = "_FUNC_(date/timestamp/string, fmt) 
- converts a date/timestamp/string "
     + "to a value of string in the format specified by the date format fmt.",
-    extended = "Supported formats are SimpleDateFormat formats - "
-        + 
"https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html. "
+    extended = "Supported formats are DateTimeFormatter formats - "
+        + 
"https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
 "

Review comment:
       This could be a breaking change. Did you verify that all the patterns 
supported in `SimpleDateFormat` are provided also by `DateTimeFormatter`?

##########
File path: ql/src/test/queries/clientpositive/udf_date_format.q
##########
@@ -78,3 +78,16 @@ select date_format("2015-04-08 10:30:45","yyyy-MM-dd 
HH:mm:ss.SSS z");
 --julian date
 set hive.local.time.zone=UTC;
 select date_format("1001-01-05","dd---MM--yyyy");
+
+--dates prior to 1900
+set hive.local.time.zone=Asia/Bangkok;
+select date_format('1400-01-14 01:01:10.123', 'yyyy-MM-dd HH:mm:ss.SSS z');
+select date_format('1800-01-14 01:01:10.123', 'yyyy-MM-dd HH:mm:ss.SSS z');
+
+set hive.local.time.zone=Europe/Berlin;
+select date_format('1400-01-14 01:01:10.123', 'yyyy-MM-dd HH:mm:ss.SSS z');
+select date_format('1800-01-14 01:01:10.123', 'yyyy-MM-dd HH:mm:ss.SSS z');
+
+set hive.local.time.zone=Africa/Johannesburg;
+select date_format('1400-01-14 01:01:10.123', 'yyyy-MM-dd HH:mm:ss.SSS z');

Review comment:
       Do we have tests where the input to `date_format` is a timestamp and not 
a string literal. In that case what should be the result of `date_format`? 
   
   Should it change when the local timezone changes or it should always be the 
same? I am asking cause if I remember well the data type that is used when we 
store timestamps in tables is `TIMESTAMP WITHOUT TIMEZONE` so in principle 
equivalent to `LocalDateTime`. From a Java perspective (using 
`DateTimeFormatter`) requesting formatting with timezone from a timestamp 
without timezone would be an error. 




-- 
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: 613543)
    Time Spent: 4h 20m  (was: 4h 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: 4h 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