HyukjinKwon commented on code in PR #47434:
URL: https://github.com/apache/spark/pull/47434#discussion_r1733780132
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/SparkSession.scala:
##########
@@ -859,6 +865,49 @@ object SparkSession extends Logging {
}
}
+ /**
+ * Create a new Spark Connect server to connect locally.
+ */
+ private[sql] def withLocalConnectServer[T](f: => T): T = {
+ synchronized {
+ val remoteString = initOptions
+ .get("spark.remote")
+ .orElse(Option(System.getProperty("spark.remote"))) // Set from Spark
Submit
+ .orElse(sys.env.get(SparkConnectClient.SPARK_REMOTE))
+
+ if (server.isEmpty && remoteString.exists(_.startsWith("local"))) {
+ val sparkHome = System.getenv("SPARK_HOME")
+ server = Some {
+ val args = Seq(
+ Paths.get(sparkHome, "sbin", "start-connect-server.sh").toString,
+ "--master",
+ remoteString.get) ++ initOptions
+ .filter(p => !p._1.startsWith("spark.remote"))
+ .flatMap { case (k, v) => Seq("--conf", s"$k=$v") }
Review Comment:
We probably should do something smarter to avoid double escaping, etc. This
is at least consistent with launching Py4J gateway server,
`pyspark.launch_gateway()` which basically does the similar thing.
--
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]