- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Can we change default hive/hbase timestamp from UTC to other timezone ?
- Labels:
-
Apache Hadoop
-
Apache HBase
-
Apache Hive
Created ‎02-14-2022 01:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hadoop components are using default timestamp as UTC. Is there any way to change the default time zone from UTC.
Now only seeing option to do the shifting using
Created ‎02-15-2022 12:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hiveserver2 runs as a java process, When running timestamp-related UDF functions in Hive, the default behavior is to use the system's timezone information to convert timestamp values. PFB
INFO : Executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e); Time taken: 0.092 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 13:17:16.204 |
+--------------------------+
1 row selected (2.413 seconds)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:17:26 IST 2022
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
To make Hive return a specific timezone with the timestamp function. please follow the steps below:
1. Go to the Cloudera Manager home page > Hive > Configuration
Under "Client Java Configuration Options", append " -Duser.timezone=UTC" in the text string (be mindful of the leading space in front, if you append to the end of existing options).
2 . Under "Java Configuration Options for HiveServer2", append the same thing to the end of the text string " -Duser.timezone=UTC".
3 . Save the configuration, then restart any HiveServer2 instances, and select Actions -> "Deploy Client Configuration" through Cloudera Manager.
To confirm the new configuration is working, see below test outputs:
Before the change (system's default timezone is IST):
INFO : Executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e); Time taken: 0.092 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 13:17:16.204 |
+--------------------------+
1 row selected (2.413 seconds)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:17:26 IST 2022
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
After the change to UTC,
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:28:05 IST 2022
INFO : Executing command(queryId=hive_20220215075824_6a58bdcb-b1b6-470d-9202-26ccfc60f521): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215075824_6a58bdcb-b1b6-470d-9202-26ccfc60f521); Time taken: 0.079 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 07:58:24.785 |
+--------------------------+
1 row selected (2.24 seconds)
Like this, you can mention hive to use other timezones.
Created ‎02-15-2022 12:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hiveserver2 runs as a java process, When running timestamp-related UDF functions in Hive, the default behavior is to use the system's timezone information to convert timestamp values. PFB
INFO : Executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e); Time taken: 0.092 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 13:17:16.204 |
+--------------------------+
1 row selected (2.413 seconds)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:17:26 IST 2022
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
To make Hive return a specific timezone with the timestamp function. please follow the steps below:
1. Go to the Cloudera Manager home page > Hive > Configuration
Under "Client Java Configuration Options", append " -Duser.timezone=UTC" in the text string (be mindful of the leading space in front, if you append to the end of existing options).
2 . Under "Java Configuration Options for HiveServer2", append the same thing to the end of the text string " -Duser.timezone=UTC".
3 . Save the configuration, then restart any HiveServer2 instances, and select Actions -> "Deploy Client Configuration" through Cloudera Manager.
To confirm the new configuration is working, see below test outputs:
Before the change (system's default timezone is IST):
INFO : Executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215131716_33c6c90b-207a-43fe-9bcf-4a52cd04de3e); Time taken: 0.092 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 13:17:16.204 |
+--------------------------+
1 row selected (2.413 seconds)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:17:26 IST 2022
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
After the change to UTC,
[hive@c2757-node3 ~]$ timedatectl | grep "Time zone"
Time zone: Asia/Kolkata (IST, +0530)
[hive@c2757-node3 ~]$ date
Tue Feb 15 13:28:05 IST 2022
INFO : Executing command(queryId=hive_20220215075824_6a58bdcb-b1b6-470d-9202-26ccfc60f521): SELECT current_timestamp()
INFO : Completed executing command(queryId=hive_20220215075824_6a58bdcb-b1b6-470d-9202-26ccfc60f521); Time taken: 0.079 seconds
INFO : OK
+--------------------------+
| _c0 |
+--------------------------+
| 2022-02-15 07:58:24.785 |
+--------------------------+
1 row selected (2.24 seconds)
Like this, you can mention hive to use other timezones.
Created ‎03-08-2022 01:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @nikrahu
We believe the Post by @ggangadharan answer your Queries. As such, We shall mark the Post as Resolved. If you have any concerns, Feel free to engage Cloudera Community via a Post.
Thanks @ggangadharan for the detailed Examples !!!
Regards, Smarak
