I am running a HIVE job with my UDF
extended class. I want to get the name of the user that submits my job, so i am using
System.getProperty("user.name");
to get the username but the problem is this is returning user mapred, and on the jobtracker the job is showing user name hdfs. I am currentely logged in as hdfs so the job is submitted by hdfs, so y is
System.getProperty("user.name");
retuning an incorrect value:- mapred
Can anyone please tell me why this is happening and any alternate of getting the user name in the evaluate method of UDF
You can use logged_in_user() which returns current user name from the session state. This is the username provided when connecting to Hive.
Hive allows users to read, write, and manage petabytes of data using SQL. Hive is built on top of Apache Hadoop, which is an open-source framework used to efficiently store and process large datasets.
Relational databases, or RDBMS, is a database that stores data in a structured format with rows and columns, a structured form called “tables.” Hive, on the other hand, is a data warehousing system that offers data analysis and queries.
Assuming you don't have Kerberos authentication enabled, the system tasks will be ran as the same user the TaskTrackers are running as (in this case mapred
, which is pretty common). This is because the TaskTrackers are running your process, not you.
Sorry, I can only answer half of your question. I don't know how to get the information from a Hive UDF.
Considering all of your UDF calls to the job have the same user... just "inject" it from outside of the script somewhere. For example, you can just add whoami
to your invocation of the sql:
hive -e "select a.col, '`whoami`' from tab1 a"
Besides, just getting it once is probably better than connecting to the JobTracker every single time the UDF runs.
I think you can look into this Job History API to get the username of the job submitter. I hope this may help.Job History link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With