Skip to content

Commit 57edfcd

Browse files
KenjiFujimayaooqinn
authored andcommitted
[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 4d1ef20 [KenjiFujima] [KYUUBI #2018] Hive Backend Engine - GetFunctions Operation 9c01940 [KenjiFujima] [KYUUBI #2018] Hive Backend Engine - GetFunctions Operation Authored-by: KenjiFujima <thanosxnicholas@gmail.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 62f685f commit 57edfcd

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.kyuubi.engine.hive.operation
19+
20+
import org.apache.hive.service.cli.operation.Operation
21+
22+
import org.apache.kyuubi.operation.OperationType
23+
import org.apache.kyuubi.session.Session
24+
25+
class GetFunctions(session: Session, catalogName: String, schemaName: String, functionName: String)
26+
extends HiveOperation(OperationType.GET_FUNCTIONS, session) {
27+
28+
override val internalHiveOperation: Operation =
29+
delegatedOperationManager.newGetFunctionsOperation(hive, catalogName, schemaName, functionName)
30+
}

externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationManager.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class HiveOperationManager() extends OperationManager("HiveOperationManager") {
8787
catalogName: String,
8888
schemaName: String,
8989
functionName: String): Operation = {
90-
throw KyuubiSQLException.featureNotSupported()
90+
val operation = new GetFunctions(session, catalogName, schemaName, functionName)
91+
addOperation(operation)
9192
}
9293

9394
override def getOperationLogRowSet(

externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ package org.apache.kyuubi.engine.hive.operation
1919

2020
import scala.collection.mutable.ArrayBuffer
2121

22+
import org.apache.hadoop.hive.ql.exec.FunctionInfo
23+
2224
import org.apache.kyuubi.engine.hive.HiveSQLEngine
2325
import org.apache.kyuubi.operation.HiveJDBCTestHelper
24-
import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.{TABLE_CAT, TABLE_CATALOG, TABLE_NAME, TABLE_SCHEM, TABLE_TYPE}
26+
import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant._
2527

2628
class HiveOperationSuite extends HiveJDBCTestHelper {
2729

@@ -130,6 +132,23 @@ class HiveOperationSuite extends HiveJDBCTestHelper {
130132
}
131133
}
132134

135+
test("get functions") {
136+
withJdbcStatement() { statement =>
137+
val metaData = statement.getConnection.getMetaData
138+
Seq("from_unixtime", "to_date", "date_format", "date_format", "round", "sin").foreach {
139+
func =>
140+
val resultSet = metaData.getFunctions(null, null, func)
141+
while (resultSet.next()) {
142+
assert(resultSet.getString(FUNCTION_CAT) === null)
143+
assert(resultSet.getString(FUNCTION_SCHEM) === null)
144+
assert(resultSet.getString(FUNCTION_NAME) === func)
145+
assert(resultSet.getString(REMARKS).isEmpty)
146+
assert(resultSet.getString(SPECIFIC_NAME) === classOf[FunctionInfo].getName)
147+
}
148+
}
149+
}
150+
}
151+
133152
test("basic execute statements, create, insert query") {
134153
withJdbcStatement("hive_engine_test") { statement =>
135154
statement.execute("CREATE TABLE hive_engine_test(id int, value string) stored as orc")

0 commit comments

Comments
 (0)