Skip to content

Commit 9f3c5c7

Browse files
SteNicholasyaooqinn
authored andcommitted
[KYUUBI #1923] Add GetFunctions for trino engine
<!-- 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/apache/incubator-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 GetFunctions for trino engine. ### _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 #1925 from SteNicholas/KYUUBI-1923. Closes #1923 4ebc64a [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine f19f518 [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine ac9df0a [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine Authored-by: SteNicholas <programgeek@163.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 9bcd08f commit 9f3c5c7

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperation.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ abstract class TrinoOperation(opType: OperationType, session: Session)
9898
override def close(): Unit = {
9999
cleanup(OperationState.CLOSED)
100100
try {
101-
trino.close()
101+
if (trino != null) {
102+
trino.close()
103+
trino = null
104+
}
102105
getOperationLog.foreach(_.close())
103106
} catch {
104107
case e: IOException =>

externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationManager.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import java.util
2121

2222
import scala.collection.JavaConverters._
2323

24+
import org.apache.kyuubi.KyuubiSQLException
2425
import org.apache.kyuubi.config.KyuubiConf.OPERATION_INCREMENTAL_COLLECT
2526
import org.apache.kyuubi.operation.{Operation, OperationManager}
2627
import org.apache.kyuubi.session.Session
@@ -91,5 +92,8 @@ class TrinoOperationManager extends OperationManager("TrinoOperationManager") {
9192
session: Session,
9293
catalogName: String,
9394
schemaName: String,
94-
functionName: String): Operation = null
95+
functionName: String): Operation = {
96+
// TODO: Supports the GetFunctions operation when Trino supports the query of the functions.
97+
throw KyuubiSQLException.featureNotSupported()
98+
}
9599
}

externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.apache.hive.service.rpc.thrift.TOpenSessionReq
3333
import org.apache.hive.service.rpc.thrift.TOperationState
3434
import org.apache.hive.service.rpc.thrift.TStatusCode
3535

36+
import org.apache.kyuubi.KyuubiSQLException
3637
import org.apache.kyuubi.config.KyuubiConf.ENGINE_TRINO_CONNECTION_CATALOG
3738
import org.apache.kyuubi.engine.trino.WithTrinoEngine
3839
import org.apache.kyuubi.operation.HiveJDBCTestHelper
@@ -557,6 +558,16 @@ class TrinoOperationSuite extends WithTrinoEngine with HiveJDBCTestHelper {
557558
}
558559
}
559560

561+
test("trino - get functions") {
562+
withJdbcStatement() { statement =>
563+
val exceptionMsg = intercept[Exception](statement.getConnection.getMetaData.getFunctions(
564+
null,
565+
null,
566+
"abs")).getMessage
567+
assert(exceptionMsg === KyuubiSQLException.featureNotSupported().getMessage)
568+
}
569+
}
570+
560571
test("execute statement - select decimal") {
561572
withJdbcStatement() { statement =>
562573
val resultSet = statement.executeQuery("SELECT DECIMAL '1.2' as col1, DECIMAL '1.23' AS col2")

0 commit comments

Comments
 (0)