HyukjinKwon commented on code in PR #40534:
URL: https://github.com/apache/spark/pull/40534#discussion_r1149935560
##########
python/pyspark/sql/utils.py:
##########
@@ -193,6 +193,15 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
return cast(FuncT, wrapped)
+def require_spark_context_initialized() -> SparkContext:
+ """Raise RuntimeError if SparkContext is not initialized,
+ otherwise, returns the active SparkContext."""
+ sc = SparkContext._active_spark_context
+ if sc is None or sc._jvm is None:
+ raise RuntimeError("SparkContext must be initialized for JVM access.")
Review Comment:
I would just say something like: `SparkContext or SparkSession should be
created first` instead
--
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]