[ 
https://issues.apache.org/jira/browse/HIVE-25093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ashish Sharma updated HIVE-25093:
---------------------------------
    Description: 
*HIVE - 1.2*

sshuser@hn0-dateti:~$ *timedatectl*

      Local time: Thu 2021-05-06 11:56:08 IST
  Universal time: Thu 2021-05-06 06:26:08 UTC
        RTC time: Thu 2021-05-06 06:26:08
       Time zone: Asia/Kolkata (IST, +0530)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

sshuser@hn0-dateti:~$ beeline
0: jdbc:hive2://localhost:10001/default> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+--+
|             _c0              |
+------------------------------+--+
| 2021-05-06 11:58:53.760 IST  |
+------------------------------+--+
1 row selected (1.271 seconds)


*HIVE - 3.1.0*

sshuser@hn0-testja:~$ *timedatectl*
      Local time: Thu 2021-05-06 12:03:32 IST
  Universal time: Thu 2021-05-06 06:33:32 UTC
        RTC time: Thu 2021-05-06 06:33:32
       Time zone: Asia/Kolkata (IST, +0530)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

sshuser@hn0-testja:~$ beeline
0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+
|             _c0              |
+------------------------------+
| *2021-05-06 06:33:59.078 UTC*  |
+------------------------------+
1 row selected (13.396 seconds)

0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *set 
hive.local.time.zone=Asia/Kolkata;*
No rows affected (0.025 seconds)
0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+
|             _c0              |
+------------------------------+
| *{color:red}2021-05-06 12:08:15.118 UTC{color}*  | 
+------------------------------+
1 row selected (1.074 seconds)

expected result was *2021-05-06 12:08:15.118 IST*


As part of HIVE-12192 it was decided to have a common time zone for all 
computation i.e. "UTC". Due to which data_format() function was hard coded to 
"UTC".

But later in HIVE-21039 it was decided that user session time zone value should 
be the default not UTC. 

date_format() was not fixed as part of HIVE-21039.

what should be the ideal time zone value of date_format().

  was:
*HIVE - 1.2*

sshuser@hn0-dateti:~$ *timedatectl*

      Local time: Thu 2021-05-06 11:56:08 IST
  Universal time: Thu 2021-05-06 06:26:08 UTC
        RTC time: Thu 2021-05-06 06:26:08
       Time zone: Asia/Kolkata (IST, +0530)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

sshuser@hn0-dateti:~$ beeline
0: jdbc:hive2://localhost:10001/default> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+--+
|             _c0              |
+------------------------------+--+
| 2021-05-06 11:58:53.760 IST  |
+------------------------------+--+
1 row selected (1.271 seconds)


*HIVE - 3.1.0*

sshuser@hn0-testja:~$ *timedatectl*
      Local time: Thu 2021-05-06 12:03:32 IST
  Universal time: Thu 2021-05-06 06:33:32 UTC
        RTC time: Thu 2021-05-06 06:33:32
       Time zone: Asia/Kolkata (IST, +0530)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

sshuser@hn0-testja:~$ beeline
0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+
|             _c0              |
+------------------------------+
| *2021-05-06 06:33:59.078 UTC*  |
+------------------------------+
1 row selected (13.396 seconds)

0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *set 
hive.local.time.zone=Asia/Kolkata;*
No rows affected (0.025 seconds)
0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
+------------------------------+
|             _c0              |
+------------------------------+
| *{color:red}2021-05-06 12:08:15.118 UTC{color}*  | 
+------------------------------+
1 row selected (1.074 seconds)

expected result was *2021-05-06 12:08:15.118 IST*


As part of HIVE-12192 it was decided to have a common time zone for all 
computation i.e. "UTC". Due to which data_format() function was hard coded to 
"UTC".

But later in HIVE-21039 it was decided that user session time zone value should 
be the default not UTC. 

date_format() was not fixed as part of HIVE-21039.

what should be the ideal time zone value of date_format().


Code - 
https://github.com/apache/hive/blob/7b3ecf617a6d46f48a3b6f77e0339fd4ad95a420/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateFormat.java

if (fmtStr != null) {
        try {
          formatter = new SimpleDateFormat(fmtStr);
         formatter.setCalendar(DateTimeMath.getProlepticGregorianCalendarUTC());
        } catch (IllegalArgumentException e) {
          // ignore
        }


> date_format() UDF is returning values in UTC time zone only 
> ------------------------------------------------------------
>
>                 Key: HIVE-25093
>                 URL: https://issues.apache.org/jira/browse/HIVE-25093
>             Project: Hive
>          Issue Type: Bug
>          Components: UDF
>    Affects Versions: 3.1.2
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Minor
>
> *HIVE - 1.2*
> sshuser@hn0-dateti:~$ *timedatectl*
>       Local time: Thu 2021-05-06 11:56:08 IST
>   Universal time: Thu 2021-05-06 06:26:08 UTC
>         RTC time: Thu 2021-05-06 06:26:08
>        Time zone: Asia/Kolkata (IST, +0530)
>  Network time on: yes
> NTP synchronized: yes
>  RTC in local TZ: no
> sshuser@hn0-dateti:~$ beeline
> 0: jdbc:hive2://localhost:10001/default> *select 
> date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
> +------------------------------+--+
> |             _c0              |
> +------------------------------+--+
> | 2021-05-06 11:58:53.760 IST  |
> +------------------------------+--+
> 1 row selected (1.271 seconds)
> *HIVE - 3.1.0*
> sshuser@hn0-testja:~$ *timedatectl*
>       Local time: Thu 2021-05-06 12:03:32 IST
>   Universal time: Thu 2021-05-06 06:33:32 UTC
>         RTC time: Thu 2021-05-06 06:33:32
>        Time zone: Asia/Kolkata (IST, +0530)
>  Network time on: yes
> NTP synchronized: yes
>  RTC in local TZ: no
> sshuser@hn0-testja:~$ beeline
> 0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
> date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
> +------------------------------+
> |             _c0              |
> +------------------------------+
> | *2021-05-06 06:33:59.078 UTC*  |
> +------------------------------+
> 1 row selected (13.396 seconds)
> 0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *set 
> hive.local.time.zone=Asia/Kolkata;*
> No rows affected (0.025 seconds)
> 0: jdbc:hive2://zk0-testja.e0mrrixnyxde5h1suy> *select 
> date_format(current_timestamp,"yyyy-MM-dd HH:mm:ss.SSS z");*
> +------------------------------+
> |             _c0              |
> +------------------------------+
> | *{color:red}2021-05-06 12:08:15.118 UTC{color}*  | 
> +------------------------------+
> 1 row selected (1.074 seconds)
> expected result was *2021-05-06 12:08:15.118 IST*
> As part of HIVE-12192 it was decided to have a common time zone for all 
> computation i.e. "UTC". Due to which data_format() function was hard coded to 
> "UTC".
> But later in HIVE-21039 it was decided that user session time zone value 
> should be the default not UTC. 
> date_format() was not fixed as part of HIVE-21039.
> what should be the ideal time zone value of date_format().



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

Reply via email to