Reputation: 23
I want to know the group name to which a particular spark user belongs from a spark application program. Currently, I can retrieve the name of a spark user using spark.sparkContext.sparkUser
Is there any API/method which will give me group name to which this spark user belongs.
I know there is a linux command id <user-name>
but my requirement is to get the group name in a programmatic manner.
Upvotes: 1
Views: 569
Reputation: 31510
Yes, we can run shell commands in spark app.
Try this way once:
import sys.process._
val user_name=spark.sparkContext.sparkUser
s"id ${user_name}".! //displays group names
Upvotes: 1