Skip to content

Commit

Permalink
Add comments and rollback test name
Browse files Browse the repository at this point in the history
  • Loading branch information
osopardo1 authored and osopardo1 committed Dec 12, 2022
1 parent 83e3e9a commit c0e9f5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class QbeastCatalog[T <: TableCatalog with SupportsNamespaces]

private var catalogName: String = null

/**
* Gets the delegated catalog of the session
* @return
*/
private def getDelegatedCatalog(): T = {
val sessionCatalog = delegatedCatalog match {
case null =>
Expand All @@ -54,6 +58,17 @@ class QbeastCatalog[T <: TableCatalog with SupportsNamespaces]
sessionCatalog.asInstanceOf[T]
}

/**
* Gets the session catalog depending on provider properties, if any
*
* The intention is to include the different catalog providers
* while we add the integrations with the formats.
* For example, for "delta" provider it will return a DeltaCatalog instance.
*
* In this way, users may only need to instantiate one single unified catalog.
* @param properties the properties with the provider parameter
* @return
*/
private def getSessionCatalog(properties: Map[String, String] = Map.empty): T = {
properties.get("provider") match {
case Some("delta") => deltaCatalog.asInstanceOf[T]
Expand Down Expand Up @@ -224,6 +239,7 @@ class QbeastCatalog[T <: TableCatalog with SupportsNamespaces]
override def initialize(name: String, options: CaseInsensitiveStringMap): Unit = {
// Initialize the catalog with the corresponding name
this.catalogName = name
// Initialize the catalog in any other provider that we can integrate with
this.deltaCatalog.initialize(name, options)
}

Expand All @@ -233,6 +249,7 @@ class QbeastCatalog[T <: TableCatalog with SupportsNamespaces]
// Check if the delegating catalog has Table and SupportsNamespace properties
if (delegate.isInstanceOf[TableCatalog] && delegate.isInstanceOf[SupportsNamespaces]) {
this.delegatedCatalog = delegate
// Set delegated catalog in any other provider that we can integrate with
this.deltaCatalog.setDelegateCatalog(delegate)
} else throw new IllegalArgumentException("Invalid session catalog: " + delegate)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.apache.spark.sql.AnalysisException
class QbeastCatalogIntegrationTest extends QbeastIntegrationTestSpec with CatalogTestSuite {

"QbeastCatalog" should
"coexist with Delta Catalog" in withTmpDir(tmpDir =>
"coexist with Delta tables" in withTmpDir(tmpDir =>
withExtendedSpark(sparkConf = new SparkConf()
.setMaster("local[8]")
.set("spark.sql.extensions", "io.qbeast.spark.internal.QbeastSparkSessionExtension")
Expand Down

0 comments on commit c0e9f5f

Please sign in to comment.