You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ya...@apache.org on 2022/02/17 11:28:18 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #1923] Add GetFunctions for trino engine
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 9f3c5c7 [KYUUBI #1923] Add GetFunctions for trino engine
9f3c5c7 is described below
commit 9f3c5c7d929d667a4777050e1b7a905ff89b8812
Author: SteNicholas <pr...@163.com>
AuthorDate: Thu Feb 17 19:28:06 2022 +0800
[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
4ebc64ae [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine
f19f5188 [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine
ac9df0a8 [SteNicholas] [KYUUBI #1923] Add GetFunctions for trino engine
Authored-by: SteNicholas <pr...@163.com>
Signed-off-by: Kent Yao <ya...@apache.org>
---
.../apache/kyuubi/engine/trino/operation/TrinoOperation.scala | 5 ++++-
.../kyuubi/engine/trino/operation/TrinoOperationManager.scala | 6 +++++-
.../kyuubi/engine/trino/operation/TrinoOperationSuite.scala | 11 +++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperation.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperation.scala
index 298034b..0da6824 100644
--- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperation.scala
+++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperation.scala
@@ -98,7 +98,10 @@ abstract class TrinoOperation(opType: OperationType, session: Session)
override def close(): Unit = {
cleanup(OperationState.CLOSED)
try {
- trino.close()
+ if (trino != null) {
+ trino.close()
+ trino = null
+ }
getOperationLog.foreach(_.close())
} catch {
case e: IOException =>
diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationManager.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationManager.scala
index 3993d9a..df4412e 100644
--- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationManager.scala
+++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationManager.scala
@@ -21,6 +21,7 @@ import java.util
import scala.collection.JavaConverters._
+import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.config.KyuubiConf.OPERATION_INCREMENTAL_COLLECT
import org.apache.kyuubi.operation.{Operation, OperationManager}
import org.apache.kyuubi.session.Session
@@ -91,5 +92,8 @@ class TrinoOperationManager extends OperationManager("TrinoOperationManager") {
session: Session,
catalogName: String,
schemaName: String,
- functionName: String): Operation = null
+ functionName: String): Operation = {
+ // TODO: Supports the GetFunctions operation when Trino supports the query of the functions.
+ throw KyuubiSQLException.featureNotSupported()
+ }
}
diff --git a/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationSuite.scala b/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationSuite.scala
index 9ef00e1..d74da72 100644
--- a/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationSuite.scala
+++ b/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/operation/TrinoOperationSuite.scala
@@ -33,6 +33,7 @@ import org.apache.hive.service.rpc.thrift.TOpenSessionReq
import org.apache.hive.service.rpc.thrift.TOperationState
import org.apache.hive.service.rpc.thrift.TStatusCode
+import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.config.KyuubiConf.ENGINE_TRINO_CONNECTION_CATALOG
import org.apache.kyuubi.engine.trino.WithTrinoEngine
import org.apache.kyuubi.operation.HiveJDBCTestHelper
@@ -557,6 +558,16 @@ class TrinoOperationSuite extends WithTrinoEngine with HiveJDBCTestHelper {
}
}
+ test("trino - get functions") {
+ withJdbcStatement() { statement =>
+ val exceptionMsg = intercept[Exception](statement.getConnection.getMetaData.getFunctions(
+ null,
+ null,
+ "abs")).getMessage
+ assert(exceptionMsg === KyuubiSQLException.featureNotSupported().getMessage)
+ }
+ }
+
test("execute statement - select decimal") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SELECT DECIMAL '1.2' as col1, DECIMAL '1.23' AS col2")