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

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

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



##########
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:
       @sankarh @zabetak 
   All the timestamps are considered to be in local time zone in both Hive 1.2 
and Hive master (patched).
   Both Hive 1.2 and 3.1 have similar results for the date_format function.
   E.g.: 
   Hive 1.2.1 (with timezone set to Asia/Bangkok)
   ```
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select * from test_tbl_orc;
   +------------------------------+--------------------------+--+
   | test_tbl_orc.clusterversion  |    test_tbl_orc.col2     |
   +------------------------------+--------------------------+--+
   | Hive 4.0                     | 1800-01-14 01:01:10.123  |
   +------------------------------+--------------------------+--+
   1 row selected (0.372 seconds)
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> desc test_tbl_orc;
   +-----------------+------------+----------+--+
   |    col_name     | data_type  | comment  |
   +-----------------+------------+----------+--+
   | clusterversion  | string     |          |
   | col2            | timestamp  |          |
   +-----------------+------------+----------+--+
   2 rows selected (0.65 seconds)
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select date_format(col2, 
"yyyy-MM-dd HH:mm:ss.SSS z") from test_tbl_orc;
   +------------------------------+--+
   |             _c0              |
   +------------------------------+--+
   | 1800-01-14 01:01:10.123 ICT  |
   +------------------------------+--+
   ```
   Hive master (using MiniHS2 and same orc file from Hive 1.2)
   ```
   0: jdbc:hive2://localhost:10000/> select * from test_tbl_orc;
   +------------------------------+--------------------------+
   | test_tbl_orc.clusterversion  |    test_tbl_orc.col2     |
   +------------------------------+--------------------------+
   | Hive 4.0                     | 1800-01-14 01:01:10.123  |
   +------------------------------+--------------------------+
   1 row selected (0.23 seconds)
   0: jdbc:hive2://localhost:10000/> desc test_tbl_orc;
   +-----------------+------------+----------+
   |    col_name     | data_type  | comment  |
   +-----------------+------------+----------+
   | clusterversion  | string     |          |
   | col2            | timestamp  |          |
   +-----------------+------------+----------+
   2 rows selected (0.24 seconds)
   0: jdbc:hive2://localhost:10000/> set hive.local.time.zone=Asia/Bangkok;
   No rows affected (0.102 seconds)
   0: jdbc:hive2://localhost:10000/> select date_format(col2, "yyyy-MM-dd 
HH:mm:ss.SSS z") from test_tbl_orc;
   +------------------------------+
   |             _c0              |
   +------------------------------+
   | 1800-01-14 01:01:10.123 ICT  |
   +------------------------------+
   1 row selected (0.261 seconds)
   0: jdbc:hive2://localhost:10000/> set hive.local.time.zone=LOCAL;
   No rows affected (0.036 seconds)
   0: jdbc:hive2://localhost:10000/> select date_format(col2, "yyyy-MM-dd 
HH:mm:ss.SSS z") from test_tbl_orc;
   +------------------------------+
   |             _c0              |
   +------------------------------+
   | 1800-01-14 01:01:10.123 PST  |
   +------------------------------+
   1 row selected (0.492 seconds)
   ```




-- 
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: 614857)
    Time Spent: 9h  (was: 8h 50m)

> 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: 9h
>  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