There is a function starting from DBR 7.3 rated as a dynamic view function to do just that -
current_user. SQL users are lucky as they can just call it from their script i.e.
select current_user as user. Unforutnately, it’s not available from Python/Scala, but one can wrap it in a function like this:
def get_current_user_name(): return (spark .createDataFrame([("",)], "user string") .withColumn("user", f.expr("current_user")) .head()["user"])
Also, unfortunately, this function will only work if spark config has the following setting on the cluster:
Em, excuse me! Have Android 📱 and use Databricks? You might be interested in my totally free (and ad-free) Pocket Bricks . You can get it from Google Play too: