MonkeyCanCode commented on code in PR #59952:
URL: https://github.com/apache/spark/pull/59952#discussion_r4429660748
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/service/SparkConnectSessionManagerSuite.scala:
##########
@@ -177,6 +178,21 @@ class SparkConnectSessionManagerSuite extends
SharedSparkSession {
"pipeline execution was not removed")
}
+ test("Catalogs loaded by the session are closed when the session holder is
closed") {
+ val key = SessionKey("user", UUID.randomUUID().toString)
+ val sessionHolder =
SparkConnectService.sessionManager.getOrCreateIsolatedSession(key, None)
+ sessionHolder.session.conf
+ .set("spark.sql.catalog.closeable", classOf[CloseableCatalog].getName)
+ // Catalogs are loaded with the active session's conf.
+ val catalog = sessionHolder.withSession {
+
_.sessionState.catalogManager.catalog("closeable").asInstanceOf[CloseableCatalog]
+ }
+ assert(!catalog.closed)
+
+ SparkConnectService.sessionManager.closeSession(sessionHolder.key)
+ assert(catalog.closed)
Review Comment:
This is fixed.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogManager.scala:
##########
@@ -156,7 +174,10 @@ private[sql] class DefaultCatalogManager(
override private[sql] def v2SessionCatalog: CatalogPlugin = {
conf.getConf(SQLConf.V2_SESSION_CATALOG_IMPLEMENTATION) match {
case "builtin" => defaultSessionCatalog
- case _ => catalogs.getOrElseUpdate(SESSION_CATALOG_NAME,
loadV2SessionCatalog())
+ case _ => catalogs.getOrElseUpdate(SESSION_CATALOG_NAME, {
+ checkNotClosed(SESSION_CATALOG_NAME)
Review Comment:
This is fixed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]