This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new cd308f3  [KYUUBI #758] [KYUUBI 661] Add UDF system_user
cd308f3 is described below

commit cd308f38adf44af72a254c4706abd0dfbef1a887
Author: Min Zhao <[email protected]>
AuthorDate: Mon Jul 19 18:16:38 2021 +0800

    [KYUUBI #758] [KYUUBI 661] Add UDF system_user
    
    <!--
    Thanks for sending a pull request!
    
    Here are some tips for you:
      1. If this is your first time, please read our contributor guidelines: 
https://kyuubi.readthedocs.io/en/latest/community/contributions.html
      2. If the PR is related to an issue in 
https://github.com/NetEase/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR 
title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
      3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][KYUUBI #XXXX] Your PR title ...'.
    -->
    
    ### _Why are the changes needed?_
    <!--
    Please clarify why the changes are needed. For instance,
      1. If you add a feature, you can talk about the use case of it.
      2. If you fix a bug, you can clarify why it is a bug.
    -->
    
    add udf system_user.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run 
test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) 
locally before make a pull request
    
    Closes #758 from zhaomin1423/661_add-system_user.
    
    Closes #758
    
    70eba56a [Min Zhao] update system user name
    f5edc621 [Min Zhao] [KYUUBI 661] Add UDF system_user
    
    Authored-by: Min Zhao <[email protected]>
    Signed-off-by: Kent Yao <[email protected]>
---
 docs/sql/functions.md                                             | 1 +
 .../scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala    | 7 +++++++
 .../src/test/scala/org/apache/kyuubi/operation/JDBCTests.scala    | 8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/docs/sql/functions.md b/docs/sql/functions.md
index 90a09e5..0415e7b 100644
--- a/docs/sql/functions.md
+++ b/docs/sql/functions.md
@@ -13,4 +13,5 @@ Kyuubi provides several auxiliary SQL functions as supplement 
to Spark's [Built-
 Name | Description | Return Type | Since
 --- | --- | --- | ---
 kyuubi_version | Return the version of Kyuubi Server | string | 1.3.0
+system_user | Return the system user name for the associated query engine | 
string | 1.3.0
 
diff --git 
a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala
 
b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala
index 98c4077..14c837a 100644
--- 
a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala
+++ 
b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/udf/KDFRegistry.scala
@@ -36,6 +36,13 @@ object KDFRegistry {
     "string",
     "1.3.0")
 
+  val system_user: KyuubiDefinedFunction = create(
+    "system_user",
+    udf(() => System.getProperty("user.name")).asNonNullable(),
+    "Return the system user name for the associated query engine",
+    "string",
+    "1.3.0")
+
   def create(
     name: String,
     udf: UserDefinedFunction,
diff --git 
a/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/JDBCTests.scala 
b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/JDBCTests.scala
index 660a1f0..fa0ed60 100644
--- a/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/JDBCTests.scala
+++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/JDBCTests.scala
@@ -359,4 +359,12 @@ trait JDBCTests extends BasicJDBCTests {
       assert(rs.getString(1) == KYUUBI_VERSION)
     }
   }
+
+  test("kyuubi defined function - system_user") {
+    withJdbcStatement() { statement =>
+      val rs = statement.executeQuery("SELECT system_user()")
+      assert(rs.next())
+      assert(rs.getString(1) == System.getProperty("user.name"))
+    }
+  }
 }

Reply via email to