You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/10/26 06:46:54 UTC

[GitHub] [incubator-kyuubi] cfmcgrady commented on a change in pull request #1274: [KYUUBI #660] Add UDF session_user

cfmcgrady commented on a change in pull request #1274:
URL: https://github.com/apache/incubator-kyuubi/pull/1274#discussion_r736200634



##########
File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala
##########
@@ -59,11 +60,23 @@ object KDFRegistry {
 
   val system_user: KyuubiDefinedFunction = create(
     "system_user",
-    udf(() => System.getProperty("user.name")).asNonNullable(),
+    udf(() => Utils.currentUser).asNonNullable(),
     "Return the system user name for the associated query engine",
     "string",
     "1.3.0")
 
+  val session_user: KyuubiDefinedFunction = create(
+    "session_user",
+    udf { () =>
+      Option(TaskContext.get()).map(_.getLocalProperty(KYUUBI_SESSION_USER_KEY)).orElse {
+        SparkSession.getActiveSession.map(_.sparkContext.getLocalProperty(KYUUBI_SESSION_USER_KEY))

Review comment:
       This code branch only works on local mode, could we add comments here?
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org