gengliangwang commented on a change in pull request #24768: [SPARK-27919][SQL]
Add v2 session catalog
URL: https://github.com/apache/spark/pull/24768#discussion_r296439683
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalog/v2/LookupCatalog.scala
##########
@@ -17,54 +17,127 @@
package org.apache.spark.sql.catalog.v2
+import scala.util.control.NonFatal
+
import org.apache.spark.annotation.Experimental
+import org.apache.spark.internal.Logging
import org.apache.spark.sql.catalyst.TableIdentifier
/**
* A trait to encapsulate catalog lookup function and helpful extractors.
*/
@Experimental
-trait LookupCatalog {
+trait LookupCatalog extends Logging {
+
+ import LookupCatalog._
+ protected def defaultCatalogName: Option[String] = None
protected def lookupCatalog(name: String): CatalogPlugin
- type CatalogObjectIdentifier = (Option[CatalogPlugin], Identifier)
+ /**
+ * Returns the default catalog. When set, this catalog is used for all
identifiers that do not
+ * set a specific catalog. When this is None, the session catalog is
responsible for the
+ * identifier.
+ *
+ * If this is None and a table's provider (source) is a v2 provider, the v2
session catalog will
+ * be used.
+ */
+ def defaultCatalog: Option[CatalogPlugin] = {
+ try {
+ defaultCatalogName.map(lookupCatalog)
+ } catch {
+ case NonFatal(e) =>
+ logError(s"Cannot load default v2 catalog: ${defaultCatalogName.get}",
e)
+ None
+ }
+ }
/**
- * Extract catalog plugin and identifier from a multi-part identifier.
+ * This catalog is a v2 catalog that delegates to the v1 session catalog. it
is used when the
+ * session catalog is responsible for an identifier, but the source requires
the v2 catalog API.
+ * this happens when the source implementation extends the v2 TableProvider
API and is not listed
Review comment:
Nit: capitalize "this"
----------------------------------------------------------------
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]