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 57edfcd  [KYUUBI #2018] Hive Backend Engine - GetFunctions Operation
57edfcd is described below

commit 57edfcd0bd7e068ee7405c93f7a1b1ca0520fff7
Author: KenjiFujima <[email protected]>
AuthorDate: Fri Mar 18 20:58:52 2022 +0800

    [KYUUBI #2018] Hive Backend Engine - GetFunctions Operation
    
    ### _Why are the changes needed?_
    
    Hive Backend Engine - GetFunctions Operation.
    
    ### _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
    
    - [x] [Run 
test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #2167 from KenjiFujima/KYUUBI-2018.
    
    Closes #2018
    
    4d1ef20d [KenjiFujima] [KYUUBI #2018] Hive Backend Engine - GetFunctions 
Operation
    9c019407 [KenjiFujima] [KYUUBI #2018] Hive Backend Engine - GetFunctions 
Operation
    
    Authored-by: KenjiFujima <[email protected]>
    Signed-off-by: Kent Yao <[email protected]>
---
 .../engine/hive/operation/GetFunctions.scala       | 30 ++++++++++++++++++++++
 .../hive/operation/HiveOperationManager.scala      |  3 ++-
 .../engine/hive/operation/HiveOperationSuite.scala | 21 ++++++++++++++-
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git 
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetFunctions.scala
 
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetFunctions.scala
new file mode 100644
index 0000000..5191b14
--- /dev/null
+++ 
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetFunctions.scala
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.engine.hive.operation
+
+import org.apache.hive.service.cli.operation.Operation
+
+import org.apache.kyuubi.operation.OperationType
+import org.apache.kyuubi.session.Session
+
+class GetFunctions(session: Session, catalogName: String, schemaName: String, 
functionName: String)
+  extends HiveOperation(OperationType.GET_FUNCTIONS, session) {
+
+  override val internalHiveOperation: Operation =
+    delegatedOperationManager.newGetFunctionsOperation(hive, catalogName, 
schemaName, functionName)
+}
diff --git 
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationManager.scala
 
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationManager.scala
index b8702c3..35277cc 100644
--- 
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationManager.scala
+++ 
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationManager.scala
@@ -87,7 +87,8 @@ class HiveOperationManager() extends 
OperationManager("HiveOperationManager") {
       catalogName: String,
       schemaName: String,
       functionName: String): Operation = {
-    throw KyuubiSQLException.featureNotSupported()
+    val operation = new GetFunctions(session, catalogName, schemaName, 
functionName)
+    addOperation(operation)
   }
 
   override def getOperationLogRowSet(
diff --git 
a/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
 
b/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
index 44d9eea..1e4d2a6 100644
--- 
a/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
+++ 
b/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
@@ -19,9 +19,11 @@ package org.apache.kyuubi.engine.hive.operation
 
 import scala.collection.mutable.ArrayBuffer
 
+import org.apache.hadoop.hive.ql.exec.FunctionInfo
+
 import org.apache.kyuubi.engine.hive.HiveSQLEngine
 import org.apache.kyuubi.operation.HiveJDBCTestHelper
-import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.{TABLE_CAT, 
TABLE_CATALOG, TABLE_NAME, TABLE_SCHEM, TABLE_TYPE}
+import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant._
 
 class HiveOperationSuite extends HiveJDBCTestHelper {
 
@@ -130,6 +132,23 @@ class HiveOperationSuite extends HiveJDBCTestHelper {
     }
   }
 
+  test("get functions") {
+    withJdbcStatement() { statement =>
+      val metaData = statement.getConnection.getMetaData
+      Seq("from_unixtime", "to_date", "date_format", "date_format", "round", 
"sin").foreach {
+        func =>
+          val resultSet = metaData.getFunctions(null, null, func)
+          while (resultSet.next()) {
+            assert(resultSet.getString(FUNCTION_CAT) === null)
+            assert(resultSet.getString(FUNCTION_SCHEM) === null)
+            assert(resultSet.getString(FUNCTION_NAME) === func)
+            assert(resultSet.getString(REMARKS).isEmpty)
+            assert(resultSet.getString(SPECIFIC_NAME) === 
classOf[FunctionInfo].getName)
+          }
+      }
+    }
+  }
+
   test("basic execute statements, create, insert query") {
     withJdbcStatement("hive_engine_test") { statement =>
       statement.execute("CREATE TABLE hive_engine_test(id int, value string) 
stored as orc")

Reply via email to