Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get hive current user name

Currently i have logged in with the user testuser1.

I need to get the Current user in my hive query (Apache hive). But hive default current_user function is returning user as a 'HIVE' user.

select current_user() - hive

How can i get an current_user as - testuser1.

like image 650
Vicky Avatar asked Dec 14 '22 00:12

Vicky


1 Answers

You can use logged_in_user() which returns current user name from the session state. This is the username provided when connecting to Hive. This function was added in Hive 2.2.0.

current_user() returns current user name from the configured authenticator manager (as of Hive 1.2.0).

Source: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

On Cloudera CDH 5.8 I get "Cloudera" when I run select current_user().

like image 161
ravi Avatar answered Jan 13 '23 19:01

ravi