kiszk commented on a change in pull request #28128:
URL: https://github.com/apache/spark/pull/28128#discussion_r420139190
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
##########
@@ -691,21 +752,56 @@ class SparkSession private(
}
// scalastyle:on
+ /**
+ * Lifecycle method that cleans up state of spark session, and mark session
+ * "ended" forever. This differs from `stop()` or `stopContext()` as it keeps
+ * the underlying `SparkContext` alive, while only getting
+ */
+
+ def terminate(): Unit = {
+ // Session is still active
+ if (!_terminated.get()) {
+ sparkContext.removeSparkListener(this._sessionListener)
+ SparkSession.removeTerminatedSession(_sessionId)
+ _terminated.set(true)
+ }
+ else {
+ throw new IllegalStateException(
+ s"""Cannot call methods on a terminated SparkSession. Call
Review comment:
nit: `s` is not necessary
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]