You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/17 05:17:55 UTC

[GitHub] [spark] stczwd commented on a change in pull request #27900: [SPARK-31100][SQL] Check namespace existens when setting namespace

stczwd commented on a change in pull request #27900: [SPARK-31100][SQL] Check namespace existens when setting namespace
URL: https://github.com/apache/spark/pull/27900#discussion_r393449523
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogManager.scala
 ##########
 @@ -106,13 +106,14 @@ class CatalogManager(
   }
 
   def setCurrentNamespace(namespace: Array[String]): Unit = synchronized {
-    if (currentCatalog.name() == SESSION_CATALOG_NAME) {
-      if (namespace.length != 1) {
+    currentCatalog match {
+      case _ if currentCatalog.name() == SESSION_CATALOG_NAME && namespace.length == 1 =>
+        v1SessionCatalog.setCurrentDatabase(namespace.head)
+      case catalog: SupportsNamespaces if catalog.namespaceExists(namespace) =>
+        logInfo(s"set current namespace to ${namespace.mkString(".")}")
+        _currentNamespace = Some(namespace)
+      case _ =>
         throw new NoSuchNamespaceException(namespace)
 
 Review comment:
   > It's very likely that the underlying catalog can't report namespace existence directly, but can throw namespace not found error when calling APIs like `loadTable(ident)`
   
   First, the user needs to sense whether the namespace exists.
   Secondly, Those who cannot obtain the namespace status can return true directly in namespaceExists.
   Finally, for those don't support namespaces, users should be allowed to set the defaultNamespace, I will add this.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org