Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Aug 7, 2019
1 parent de95b81 commit e85f495
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Expand Up @@ -44,7 +44,7 @@ class CatalogManager(conf: SQLConf) extends Logging {
/**
* Returns the default catalog specified by config.
*/
def defaultCatalog(): Option[CatalogPlugin] = {
def defaultCatalog: Option[CatalogPlugin] = {
conf.defaultV2Catalog.flatMap { catalogName =>
try {
Some(catalog(catalogName))
Expand All @@ -56,7 +56,7 @@ class CatalogManager(conf: SQLConf) extends Logging {
}
}

def v2SessionCatalog(): Option[CatalogPlugin] = {
def v2SessionCatalog: Option[CatalogPlugin] = {
try {
Some(catalog(CatalogManager.SESSION_CATALOG_NAME))
} catch {
Expand All @@ -67,7 +67,7 @@ class CatalogManager(conf: SQLConf) extends Logging {
}

// Clear all the registered catalogs. Only used in tests.
def reset(): Unit = catalogs.clear()
private[sql] def reset(): Unit = catalogs.clear()
}

object CatalogManager {
Expand Down
Expand Up @@ -37,15 +37,15 @@ trait LookupCatalog extends Logging {
* 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] = catalogManager.defaultCatalog()
def defaultCatalog: Option[CatalogPlugin] = catalogManager.defaultCatalog

/**
* 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
* in the fallback configuration, spark.sql.sources.write.useV1SourceList
*/
def sessionCatalog: Option[CatalogPlugin] = catalogManager.v2SessionCatalog()
def sessionCatalog: Option[CatalogPlugin] = catalogManager.v2SessionCatalog

/**
* Extract catalog plugin and remaining identifier names.
Expand Down
Expand Up @@ -44,7 +44,7 @@ class LookupCatalogSuite extends SparkFunSuite with LookupCatalog with Inside {
val name = invocation.getArgument[String](0)
catalogs.getOrElse(name, throw new CatalogNotFoundException(s"$name not found"))
})
when(manager.defaultCatalog()).thenReturn(None)
when(manager.defaultCatalog).thenReturn(None)
manager
}

Expand Down Expand Up @@ -136,7 +136,7 @@ class LookupCatalogWithDefaultSuite extends SparkFunSuite with LookupCatalog wit
val name = invocation.getArgument[String](0)
catalogs.getOrElse(name, throw new CatalogNotFoundException(s"$name not found"))
})
when(manager.defaultCatalog()).thenReturn(catalogs.get("prod"))
when(manager.defaultCatalog).thenReturn(catalogs.get("prod"))
manager
}

Expand Down
Expand Up @@ -67,8 +67,8 @@ class PlanResolutionSuite extends AnalysisTest {
throw new CatalogNotFoundException(s"No such catalog: $name")
}
})
when(manager.defaultCatalog()).thenReturn(Some(testCat))
when(manager.v2SessionCatalog()).thenCallRealMethod()
when(manager.defaultCatalog).thenReturn(Some(testCat))
when(manager.v2SessionCatalog).thenCallRealMethod()
manager
}
}
Expand All @@ -86,8 +86,8 @@ class PlanResolutionSuite extends AnalysisTest {
throw new CatalogNotFoundException(s"No such catalog: $name")
}
})
when(manager.defaultCatalog()).thenReturn(None)
when(manager.v2SessionCatalog()).thenCallRealMethod()
when(manager.defaultCatalog).thenReturn(None)
when(manager.v2SessionCatalog).thenCallRealMethod()
manager
}
}
Expand Down

0 comments on commit e85f495

Please sign in to comment.