huaxingao commented on a change in pull request #30473:
URL: https://github.com/apache/spark/pull/30473#discussion_r528916478



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalog.scala
##########
@@ -170,6 +174,125 @@ class JDBCTableCatalog extends TableCatalog with Logging {
     }
   }
 
+  override def namespaceExists(namespace: Array[String]): Boolean = namespace 
match {
+    case Array(db) =>
+      listNamespaces.exists (_(0) == db)
+    case _ => false
+  }
+
+  override def listNamespaces(): Array[Array[String]] = {
+    withConnection { conn =>
+      val catalogs = conn.getMetaData.getCatalogs()
+      catalogs.next()
+      val catalog = catalogs.getString(1)
+      val schemaBuilder = ArrayBuilder.make[Array[String]]
+      val result = conn.getMetaData.getSchemas(catalog, null)
+      while(result.next()) {
+        schemaBuilder += Array(result.getString(1))
+      }
+      schemaBuilder.result
+    }
+  }
+
+  override def listNamespaces(namespace: Array[String]): Array[Array[String]] 
= {
+    namespace match {
+      case Array() =>
+        listNamespaces()
+      case Array(db) if listNamespaces.exists (_(0) == db) =>
+        Array()
+      case _ =>
+        throw new NoSuchNamespaceException(namespace)
+    }
+  }
+
+  override def loadNamespaceMetadata(namespace: Array[String]): 
util.Map[String, String] = {
+    namespace match {
+      case Array(_) =>
+        mutable.HashMap[String, String]().asJava

Review comment:
       Seems to me the only property we can support for name space is schema 
comment. I don't have a good way to retrieve schema comment, so I will return 
an empty map for now.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to