Reputation: 829
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.
Upvotes: 5
Views: 22352
Reputation: 1088
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().
Upvotes: 14