How to find the actual user who execute a hive query
Recently my client ask me, how can I find the real user who execute a job using hive?
When executing a job via hive, if we check the job status in YARN, the job will be executed using hive user when user impersonation is active. This is not very useful when we want to know the owner of the query. After some digging, I found out how to find the actual user.
Below are the steps to find out the actual user. It may vary a bit depending on the job status, whether it is currently running or already completed.
1. Find your job in cloudera manager/Resource Manager UI and Click the Job ID Link. This will bring to the Job UI
2. On the job page, If the job is still running then you can open click on the Application Master Link. If the job has finished, then you can click on the History Link.
3. That will open the job detail page below. Then click Configuration link from the side menu.
4. Search for "hive.access.subject.name", then you will find the actual user who execute the query.
That's it, I hope this helps.