Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Hadoop environment variable or configuration variable to get the logged in user

avatar
Rising Star

In the Hadoop config files, we have some limited variable substitution, e.g. ${user.name} is replaced by the Linux-level effective user of the hadoop daemon that accesses a given config. Is there a substitution variable to get the Hadoop-level effective user? For instance, if I connect as “jkotireddy” to HiveServer2 using Beeline, ${user.name} expands to "hive" because that's the Linux-level effective user of HiveServer2; are there any other configuration variables which gives “jkotireddy” ?

1 ACCEPTED SOLUTION

avatar

Remember when you connect to HiveServer2 over JDBC you are running commands at the HiveServer2, so your client environment properties are not available. You can however pass additional properties at the time of initiating beeline session:

$ beeline -hiveconf hs2.connect.user=deepesh
beeline> !connect jdbc:hive2://localhost:10000 hrt pwd
scan complete in 2ms
Connecting to jdbc:hive2://localhost:10000
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000> set hs2.connect.user;
+---------------------------+--+
|            set            |
+---------------------------+--+
| hs2.connect.user=deepesh  |
+---------------------------+--+
1 row selected (0.112 seconds)

View solution in original post

2 REPLIES 2

avatar

Remember when you connect to HiveServer2 over JDBC you are running commands at the HiveServer2, so your client environment properties are not available. You can however pass additional properties at the time of initiating beeline session:

$ beeline -hiveconf hs2.connect.user=deepesh
beeline> !connect jdbc:hive2://localhost:10000 hrt pwd
scan complete in 2ms
Connecting to jdbc:hive2://localhost:10000
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000> set hs2.connect.user;
+---------------------------+--+
|            set            |
+---------------------------+--+
| hs2.connect.user=deepesh  |
+---------------------------+--+
1 row selected (0.112 seconds)

avatar
Rising Star

@Deepesh i required to get the user . if i call the variable ${user.name} - i will get the value as hive, but i required to get the user . The reason we'd like this is to store AWS access credentials for S3 on each user's HDFS directory (e.g., hdfs://user/jkotireddy/aws_credentials) and have the S3 libraries automatically pick them up. We'd like to set this variable to something like "hdfs://user/${user.name}/aws_credentials". - want a config variable which gives me the Hadoop-level effective user.