imback82 commented on a change in pull request #25771: [SPARK-28970][SQL] 
Implement USE CATALOG/NAMESPACE for Data Source V2
URL: https://github.com/apache/spark/pull/25771#discussion_r326845256
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceResolution.scala
 ##########
 @@ -210,6 +197,17 @@ case class DataSourceResolution(
           }
           ShowTablesCommand(Some(namespace.quoted), pattern)
       }
+
+    case UseCatalogAndNamespaceStatement(catalogName, namespace) =>
+      catalogName match {
+        case Some(c) =>
+          validateCatalog(c)
+          UseCatalogAndNamespace(catalogManager, Some(c), namespace)
+        case None =>
+          require(namespace.nonEmpty)
+          val CurrentCatalogAndNamespace(catalog, ns) = namespace.get
+          UseCatalogAndNamespace(catalogManager, Some(catalog.name()), 
Some(ns))
 
 Review comment:
   Actually, this may not be correct if the catalog is `V2SessionCatalog`. The 
V1 behavior is that it calls `SessionCatalog.setCurrentDatabase(databaseName)`. 
So if we don't fallback to V1, any code that access 
`SessionCatalog.getCurrentDatabase` can be broken.
   

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


With regards,
Apache Git Services

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

Reply via email to