grundprinzip commented on code in PR #41097:
URL: https://github.com/apache/spark/pull/41097#discussion_r1188558742
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/SparkSession.scala:
##########
@@ -586,24 +610,50 @@ object SparkSession extends Logging {
}
class Builder() extends Logging {
- private var _client: SparkConnectClient = _
+ private val builder = SparkConnectClient.builder()
+ private var client: SparkConnectClient = _
def remote(connectionString: String): Builder = {
-
client(SparkConnectClient.builder().connectionString(connectionString).build())
+ builder.connectionString(connectionString)
this
}
private[sql] def client(client: SparkConnectClient): Builder = {
- _client = client
+ this.client = client
this
}
- def build(): SparkSession = {
- if (_client == null) {
- _client = SparkConnectClient.builder().build()
+ private def tryCreateSessionFromClient(): Option[SparkSession] = {
+ if (client != null) {
+ Option(new SparkSession(client, cleaner, planIdGenerator))
+ } else {
+ None
}
- new SparkSession(_client, cleaner, planIdGenerator)
}
+
+ /**
+ * Build the [[SparkSession]].
+ *
+ * This will try to reuse an existing session if has the same
configuration.
+ */
+ def build(): SparkSession = {
Review Comment:
ups, sorry.
--
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]