brkyvz commented on a change in pull request #25104: [SPARK-28341][SQL] create 
a public API for V2SessionCatalog
URL: https://github.com/apache/spark/pull/25104#discussion_r321851494
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalog/v2/CatalogManager.scala
 ##########
 @@ -47,13 +51,26 @@ class CatalogManager(conf: SQLConf) extends Logging {
     }
   }
 
-  def v2SessionCatalog: Option[CatalogPlugin] = {
-    try {
-      Some(catalog(CatalogManager.SESSION_CATALOG_NAME))
-    } catch {
-      case NonFatal(e) =>
-        logError("Cannot load v2 session catalog", e)
-        None
+  private def loadV2SessionCatalog(): CatalogPlugin = {
+    Catalogs.load(CatalogManager.SESSION_CATALOG_NAME, conf) match {
+      case extension: CatalogExtension =>
+        extension.setDelegateCatalog(defaultSessionCatalog)
+        extension
+      case other => other
+    }
+  }
+
+  // If the V2_SESSION_CATALOG config is specified, we try to instantiate the 
user-specified v2
+  // session catalog. Otherwise, return the default session catalog.
+  def v2SessionCatalog: CatalogPlugin = {
+    if (conf.getConf(SQLConf.V2_SESSION_CATALOG).isDefined) {
+      try {
+        catalogs.getOrElseUpdate(CatalogManager.SESSION_CATALOG_NAME, 
loadV2SessionCatalog())
+      } catch {
+        case NonFatal(_) => defaultSessionCatalog
 
 Review comment:
   I'd log the error. The user asked for a specific catalog, but we're giving 
them the default. There's no way to figure out the discrepancy without having 
the error

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