cloud-fan commented on a change in pull request #27550: [SPARK-30799][SQL] 
CatalogAndIdentifier shouldn't return wrong namespace
URL: https://github.com/apache/spark/pull/27550#discussion_r378646556
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala
 ##########
 @@ -103,16 +103,7 @@ private[sql] trait LookupCatalog extends Logging {
     def unapply(nameParts: Seq[String]): Option[(CatalogPlugin, Identifier)] = 
{
       assert(nameParts.nonEmpty)
       if (nameParts.length == 1) {
-        // If the current catalog is session catalog, the current namespace is 
not used because
-        // the single-part name could be referencing a temp view, which 
doesn't belong to any
-        // namespaces. An empty namespace will be resolved inside the session 
catalog
-        // implementation when a relation is looked up.
-        val ns = if (CatalogV2Util.isSessionCatalog(currentCatalog)) {
-          Array.empty[String]
-        } else {
-          catalogManager.currentNamespace
-        }
-        Some((currentCatalog, Identifier.of(ns, nameParts.head)))
+        Some((currentCatalog, Identifier.of(catalogManager.currentNamespace, 
nameParts.head)))
 
 Review comment:
   if you look at `SessionCatalog.setCurrentDatabase`, we forbid to set 
`global_temp` as the current database.
   
   This is to make the resolution of temp view simple: we look up temp view via 
the name parts given by users literally. No name extension is allowed.
   
   The general rule of relation resolution is: we try to look up temp view 
first, then tables/permanent views. When we call `CatalogAndIdentifier`, the 
temp view lookup should already be tried, or the caller side don't want to 
resolve temp views.
   

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