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 f22a14f [KYUUBI #2017] Hive Backend Engine - GetColumns Operation
f22a14f is described below
commit f22a14f1e50af6faad2a64902367af3f63a4ffc9
Author: KenjiFujima <[email protected]>
AuthorDate: Sat Mar 19 14:55:48 2022 +0800
[KYUUBI #2017] Hive Backend Engine - GetColumns Operation
### _Why are the changes needed?_
Hive Backend Engine - GetColumns 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 #2171 from KenjiFujima/KYUUBI-2017.
Closes #2017
dbd4c473 [KenjiFujima] [KYUUBI #2017] Hive Backend Engine - GetColumns
Operation
Authored-by: KenjiFujima <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
---
.../kyuubi/engine/hive/operation/GetColumns.scala | 40 ++++++++++++
.../hive/operation/HiveOperationManager.scala | 3 +-
.../engine/hive/operation/HiveOperationSuite.scala | 74 ++++++++++++++++++++++
3 files changed, 116 insertions(+), 1 deletion(-)
diff --git
a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetColumns.scala
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetColumns.scala
new file mode 100644
index 0000000..2e4bb78
--- /dev/null
+++
b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/GetColumns.scala
@@ -0,0 +1,40 @@
+/*
+ * 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 GetColumns(
+ session: Session,
+ catalogName: String,
+ schemaName: String,
+ tableName: String,
+ columnName: String)
+ extends HiveOperation(OperationType.GET_COLUMNS, session) {
+
+ override val internalHiveOperation: Operation =
+ delegatedOperationManager.newGetColumnsOperation(
+ hive,
+ catalogName,
+ schemaName,
+ tableName,
+ columnName)
+}
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 68a4082..ef95dd5 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
@@ -80,7 +80,8 @@ class HiveOperationManager() extends
OperationManager("HiveOperationManager") {
schemaName: String,
tableName: String,
columnName: String): Operation = {
- throw KyuubiSQLException.featureNotSupported()
+ val operation = new GetColumns(session, catalogName, schemaName,
tableName, columnName)
+ addOperation(operation)
}
override def newGetFunctionsOperation(
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 1afe089..8d03ccd 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
@@ -132,6 +132,80 @@ class HiveOperationSuite extends HiveJDBCTestHelper {
}
}
+ test("get columns") {
+ withDatabases("test_schema") { statement =>
+ statement.execute("CREATE SCHEMA IF NOT EXISTS test_schema")
+ statement.execute("CREATE TABLE IF NOT EXISTS test_schema.test_table(a
int, b string)")
+
+ try {
+ val meta = statement.getConnection.getMetaData
+ var resultSet = meta.getColumns(null, null, null, null)
+ var resultSetBuffer = ArrayBuffer[(String, String, String, String,
String)]()
+ while (resultSet.next()) {
+ resultSetBuffer += Tuple5(
+ resultSet.getString(TABLE_CAT),
+ resultSet.getString(TABLE_SCHEM),
+ resultSet.getString(TABLE_NAME),
+ resultSet.getString(COLUMN_NAME),
+ resultSet.getString(TYPE_NAME))
+ }
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"a", "INT")))
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"b", "STRING")))
+
+ resultSet = meta.getColumns("", null, null, null)
+ resultSetBuffer.clear()
+ while (resultSet.next()) {
+ resultSetBuffer += Tuple5(
+ resultSet.getString(TABLE_CAT),
+ resultSet.getString(TABLE_SCHEM),
+ resultSet.getString(TABLE_NAME),
+ resultSet.getString(COLUMN_NAME),
+ resultSet.getString(TYPE_NAME))
+ }
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"a", "INT")))
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"b", "STRING")))
+
+ resultSet = meta.getColumns(null, "test_schema", null, null)
+ resultSetBuffer.clear()
+ while (resultSet.next()) {
+ resultSetBuffer += Tuple5(
+ resultSet.getString(TABLE_CAT),
+ resultSet.getString(TABLE_SCHEM),
+ resultSet.getString(TABLE_NAME),
+ resultSet.getString(COLUMN_NAME),
+ resultSet.getString(TYPE_NAME))
+ }
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"a", "INT")))
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"b", "STRING")))
+
+ resultSet = meta.getColumns(null, null, "test_table", null)
+ resultSetBuffer.clear()
+ while (resultSet.next()) {
+ resultSetBuffer += Tuple5(
+ resultSet.getString(TABLE_CAT),
+ resultSet.getString(TABLE_SCHEM),
+ resultSet.getString(TABLE_NAME),
+ resultSet.getString(COLUMN_NAME),
+ resultSet.getString(TYPE_NAME))
+ }
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"a", "INT")))
+ assert(resultSetBuffer.contains((null, "test_schema", "test_table",
"b", "STRING")))
+
+ resultSet = meta.getColumns(null, null, null, "a")
+ while (resultSet.next()) {
+ assert(resultSet.getString(TABLE_CAT) == null)
+ assert(resultSet.getString(TABLE_SCHEM) == "test_schema")
+ assert(resultSet.getString(TABLE_NAME) == "test_table")
+ assert(resultSet.getString(COLUMN_NAME) == "a")
+ assert(resultSet.getString(TYPE_NAME) == "INT")
+ }
+ } finally {
+ statement.execute("DROP VIEW test_schema.test_view")
+ statement.execute("DROP TABLE test_schema.test_table")
+ }
+ }
+ }
+
test("get functions") {
withJdbcStatement() { statement =>
val metaData = statement.getConnection.getMetaData