beliefer commented on code in PR #43959:
URL: https://github.com/apache/spark/pull/43959#discussion_r1407020765


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -415,35 +408,28 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
     }
   }
 
-  private def getNamespace(catalog: CatalogPlugin, ns: Seq[String]): Database 
= catalog match {
-    case catalog: SupportsNamespaces =>
-      val metadata = catalog.loadNamespaceMetadata(ns.toArray)
-      new Database(
-        name = ns.quoted,
-        catalog = catalog.name,
-        description = metadata.get(SupportsNamespaces.PROP_COMMENT),
-        locationUri = metadata.get(SupportsNamespaces.PROP_LOCATION))
-    // If the catalog doesn't support namespaces, we assume it's an implicit 
namespace, which always
-    // exists but has no metadata.
-    case catalog: CatalogPlugin =>
-      new Database(
-        name = ns.quoted,
-        catalog = catalog.name,
-        description = null,
-        locationUri = null)
-    case _ => new Database(name = ns.quoted, description = null, locationUri = 
null)
-  }
-
   /**
    * Gets the database with the specified name. This throws an 
`AnalysisException` when no
    * `Database` can be found.
    */
   override def getDatabase(dbName: String): Database = {
-    val namespace = resolveNamespace(dbName)
-    val plan = UnresolvedNamespace(namespace)
+    makeDatabase(None, dbName)
+  }
+
+  private def makeDatabase(catalogNameOpt: Option[String], dbName: String): 
Database = {
+    val idents = catalogNameOpt match {
+      case Some(catalogName) => catalogName +: parseIdent(dbName)
+      case None => resolveNamespace(dbName)
+    }
+    val plan = UnresolvedNamespace(idents, true)

Review Comment:
   It seems the created `UnresolvedNamespace(idents, true)` only used once, 
it's really worth?



##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -415,35 +408,28 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
     }
   }
 
-  private def getNamespace(catalog: CatalogPlugin, ns: Seq[String]): Database 
= catalog match {
-    case catalog: SupportsNamespaces =>
-      val metadata = catalog.loadNamespaceMetadata(ns.toArray)
-      new Database(
-        name = ns.quoted,
-        catalog = catalog.name,
-        description = metadata.get(SupportsNamespaces.PROP_COMMENT),
-        locationUri = metadata.get(SupportsNamespaces.PROP_LOCATION))
-    // If the catalog doesn't support namespaces, we assume it's an implicit 
namespace, which always
-    // exists but has no metadata.
-    case catalog: CatalogPlugin =>
-      new Database(
-        name = ns.quoted,
-        catalog = catalog.name,
-        description = null,
-        locationUri = null)
-    case _ => new Database(name = ns.quoted, description = null, locationUri = 
null)
-  }
-
   /**
    * Gets the database with the specified name. This throws an 
`AnalysisException` when no
    * `Database` can be found.
    */
   override def getDatabase(dbName: String): Database = {
-    val namespace = resolveNamespace(dbName)
-    val plan = UnresolvedNamespace(namespace)
+    makeDatabase(None, dbName)

Review Comment:
   Shall we inline `makeDatabase` into `getDatabase`?



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

To unsubscribe, e-mail: [email protected]

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