You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/03/17 04:38:26 UTC

[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #2155: [KYUUBI #2016] Hive Backend Engine - GetTables Operation

yaooqinn commented on a change in pull request #2155:
URL: https://github.com/apache/incubator-kyuubi/pull/2155#discussion_r828747854



##########
File path: externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
##########
@@ -63,6 +63,71 @@ class HiveOperationSuite extends HiveJDBCTestHelper {
     }
   }
 
+  test("get tables") {
+    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 string)")
+      statement.execute(
+        "CREATE OR REPLACE VIEW test_schema.test_view AS SELECT  * FROM test_schema.test_table")
+
+      val meta = statement.getConnection.getMetaData
+      var resultSet = meta.getTables(null, null, null, null)
+      val resultSetBuffer = ArrayBuffer[(String, String, String, String)]()
+      while (resultSet.next()) {
+        resultSetBuffer += Tuple4(
+          resultSet.getString(TABLE_CAT),
+          resultSet.getString(TABLE_SCHEM),
+          resultSet.getString(TABLE_NAME),
+          resultSet.getString(TABLE_TYPE))
+      }
+      assert(resultSetBuffer.contains(("", "test_schema", "test_table", "TABLE")))
+      assert(resultSetBuffer.contains(("", "test_schema", "test_view", "VIEW")))
+
+      resultSet = meta.getTables("", null, null, null)
+      resultSetBuffer.clear()
+      while (resultSet.next()) {
+        resultSetBuffer += Tuple4(
+          resultSet.getString(TABLE_CAT),
+          resultSet.getString(TABLE_SCHEM),
+          resultSet.getString(TABLE_NAME),
+          resultSet.getString(TABLE_TYPE))
+      }
+      assert(resultSetBuffer.contains(("", "test_schema", "test_table", "TABLE")))
+      assert(resultSetBuffer.contains(("", "test_schema", "test_view", "VIEW")))
+
+      resultSet = meta.getTables(null, "test_schema", null, null)
+      resultSetBuffer.clear()
+      while (resultSet.next()) {
+        resultSetBuffer += Tuple4(
+          resultSet.getString(TABLE_CAT),
+          resultSet.getString(TABLE_SCHEM),
+          resultSet.getString(TABLE_NAME),
+          resultSet.getString(TABLE_TYPE))
+      }
+      assert(resultSetBuffer.contains(("", "test_schema", "test_table", "TABLE")))
+      assert(resultSetBuffer.contains(("", "test_schema", "test_view", "VIEW")))
+
+      resultSet = meta.getTables(null, null, "test_table", null)
+      while (resultSet.next()) {
+        assert(resultSet.getString(TABLE_CAT) == "")
+        assert(resultSet.getString(TABLE_SCHEM) == "test_schema")
+        assert(resultSet.getString(TABLE_NAME) == "test_table")
+        assert(resultSet.getString(TABLE_TYPE) == "TABLE")
+      }
+
+      resultSet = meta.getTables(null, null, null, Array("VIEW"))
+      while (resultSet.next()) {
+        assert(resultSet.getString(TABLE_CAT) == "")
+        assert(resultSet.getString(TABLE_SCHEM) == "test_schema")
+        assert(resultSet.getString(TABLE_NAME) == "test_view")
+        assert(resultSet.getString(TABLE_TYPE) == "VIEW")
+      }
+
+      statement.execute("DROP VIEW test_schema.test_view")

Review comment:
       do this in finally?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org