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


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -516,18 +516,11 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
    * Checks if the database with the specified name exists.
    */
   override def databaseExists(dbName: String): Boolean = {
-    // To maintain backwards compatibility, we first treat the input is a 
simple dbName and check
-    // if sessionCatalog contains it. If no, we try to parse it, resolve 
catalog and namespace,
-    // and check if namespace exists in the catalog.
-    if (!sessionCatalog.databaseExists(dbName)) {
-      val plan = UnresolvedNamespace(parseIdent(dbName))
-      sparkSession.sessionState.executePlan(plan).analyzed match {
-        case ResolvedNamespace(catalog: SupportsNamespaces, ns) =>
-          catalog.namespaceExists(ns.toArray)
-        case _ => true
-      }
-    } else {
-      true
+    val plan = 
DescribeNamespace(UnresolvedNamespace(resolveNamespace(dbName)), false)
+    sparkSession.sessionState.executePlan(plan).analyzed match {
+      case DescribeNamespace(ResolvedNamespace(catalog: SupportsNamespaces, 
ns), _, _) =>
+        catalog.namespaceExists(ns.toArray)

Review Comment:
   It is because 
https://github.com/apache/spark/blob/9c21238ce0e6bec676213f4bad4bc1bf4ac16932/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala#L67-L68
 only checks whether Catalog exists if I understand correctly



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