cloud-fan commented on code in PR #54429:
URL: https://github.com/apache/spark/pull/54429#discussion_r2847993550
##########
python/pyspark/sql/session.py:
##########
@@ -610,12 +610,16 @@ def create(self) -> "SparkSession":
from pyspark.core.context import SparkContext
with self._lock:
- # Build SparkConf from options
- sparkConf = SparkConf()
- for key, value in self._options.items():
- sparkConf.set(key, str(value))
-
- sc = SparkContext.getOrCreate(sparkConf)
+ instantiated_session = SparkSession._instantiatedSession
+ # Get SparkContext
+ if instantiated_session is None or
instantiated_session._sc._jsc is None:
Review Comment:
nit: I feel it's more readable to write the condition in a positive way:
```
if instantiated_session is not None or instantiated_session._sc._jsc is not
None:
// return existing SparkContext
...
else:
...
```
--
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]