amaliujia commented on code in PR #36641: URL: https://github.com/apache/spark/pull/36641#discussion_r896163957
########## 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: hmm I don't know how to deal with nested namespace without the help of SQL analyzer. I am using `sparkSession.sessionState.catalogManager.catalog(catalog_name)` to check if a database exists. Maybe we should add a V2 command to handle nested namespace? If I handle by calling `catalogManager`, it seems not to be extensible? -- 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