cloud-fan commented on code in PR #36641:
URL: https://github.com/apache/spark/pull/36641#discussion_r896288305


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -287,16 +294,44 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
    * Checks if the database with the specified name exists.
    */
   override def databaseExists(dbName: String): Boolean = {
-    sessionCatalog.databaseExists(dbName)
+    // 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 as 3 part 
name. If the parased
+    // identifier contains both catalog name and database name, we then search 
the database in the
+    // catalog.
+    if (!sessionCatalog.databaseExists(dbName)) {
+      val ident = 
sparkSession.sessionState.sqlParser.parseMultipartIdentifier(dbName)
+      if (ident.length == 2) {

Review Comment:
   We can follow what we did in `makeTable`: Create a `UnresolvedNamespace` 
logical plan and resolve it.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to