This is an automated email from the ASF dual-hosted git repository.
chengpan 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 07d3632 [KYUUBI #2015] Hive Backend Engine - GetSchemas Operation
07d3632 is described below
commit 07d363204a52a0969bd3e32a2da131d18d3ee78d
Author: SteNicholas <[email protected]>
AuthorDate: Wed Mar 16 09:41:07 2022 +0800
[KYUUBI #2015] Hive Backend Engine - GetSchemas Operation
### _Why are the changes needed?_
Hive Backend Engine - GetSchemas 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 #2144 from SteNicholas/KYUUBI-2015.
Closes #2015
8a305031 [SteNicholas] [KYUUBI #2015] Hive Backend Engine - GetSchemas
Operation
Authored-by: SteNicholas <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../kyuubi/engine/hive/operation/GetCatalogs.scala | 3 +--
.../{GetCatalogs.scala => GetSchemas.scala} | 7 +++---
.../hive/operation/HiveOperationManager.scala | 3 ++-
.../engine/hive/operation/HiveOperationSuite.scala | 25 ++++++++++++++++++++++
4 files changed, 31 insertions(+), 7 deletions(-)
diff --git
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
index af5e846..8dad3fb 100644
---
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
+++
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
@@ -22,8 +22,7 @@ import org.apache.hive.service.cli.operation.Operation
import org.apache.kyuubi.operation.OperationType
import org.apache.kyuubi.session.Session
-class GetCatalogs(
- session: Session)
+class GetCatalogs(session: Session)
extends HiveOperation(OperationType.GET_CATALOGS, session) {
override val internalHiveOperation: Operation =
diff --git
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetSchemas.scala
similarity index 82%
copy from
externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
copy to
externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetSchemas.scala
index af5e846..3e7e1f6 100644
---
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetCatalogs.scala
+++
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetSchemas.scala
@@ -22,10 +22,9 @@ import org.apache.hive.service.cli.operation.Operation
import org.apache.kyuubi.operation.OperationType
import org.apache.kyuubi.session.Session
-class GetCatalogs(
- session: Session)
- extends HiveOperation(OperationType.GET_CATALOGS, session) {
+class GetSchemas(session: Session, catalogName: String, schemaName: String)
+ extends HiveOperation(OperationType.GET_SCHEMAS, session) {
override val internalHiveOperation: Operation =
- delegatedOperationManager.newGetCatalogsOperation(hive)
+ delegatedOperationManager.newGetSchemasOperation(hive, catalogName,
schemaName)
}
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 5232bb5..064d864 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
@@ -55,7 +55,8 @@ class HiveOperationManager() extends
OperationManager("HiveOperationManager") {
session: Session,
catalog: String,
schema: String): Operation = {
- throw KyuubiSQLException.featureNotSupported()
+ val operation = new GetSchemas(session, catalog, schema)
+ addOperation(operation)
}
override def newGetTablesOperation(
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 5ba7d20..096d3ce 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
@@ -17,8 +17,11 @@
package org.apache.kyuubi.engine.hive.operation
+import scala.collection.mutable.ArrayBuffer
+
import org.apache.kyuubi.engine.hive.HiveSQLEngine
import org.apache.kyuubi.operation.HiveJDBCTestHelper
+import
org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.{TABLE_CATALOG,
TABLE_SCHEM}
class HiveOperationSuite extends HiveJDBCTestHelper {
@@ -38,6 +41,28 @@ class HiveOperationSuite extends HiveJDBCTestHelper {
}
}
+ test("get schemas") {
+ withDatabases("test_schema") { statement =>
+ statement.execute("CREATE SCHEMA IF NOT EXISTS test_schema")
+ val metaData = statement.getConnection.getMetaData
+ var resultSet = metaData.getSchemas(null, null)
+ val resultSetBuffer = ArrayBuffer[(String, String)]()
+ while (resultSet.next()) {
+ resultSetBuffer += Tuple2(
+ resultSet.getString(TABLE_CATALOG),
+ resultSet.getString(TABLE_SCHEM))
+ }
+ assert(resultSetBuffer.contains(("", "default")))
+ assert(resultSetBuffer.contains(("", "test_schema")))
+
+ resultSet = metaData.getSchemas("", "test")
+ while (resultSet.next()) {
+ assert(resultSet.getString(TABLE_CATALOG) == "")
+ assert(resultSet.getString(TABLE_SCHEM) == "test_schema")
+ }
+ }
+ }
+
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")