cloud-fan 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_r393438037
########## 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: And we should allow users to set current namespace when working with these catalogs. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org