You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by HyukjinKwon <gi...@git.apache.org> on 2018/10/03 17:12:05 UTC
[GitHub] spark pull request #22295: [SPARK-25255][PYTHON]Add getActiveSession to Spar...
Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/22295#discussion_r222392450
--- Diff: python/pyspark/sql/session.py ---
@@ -252,6 +255,20 @@ def newSession(self):
"""
return self.__class__(self._sc, self._jsparkSession.newSession())
+ @classmethod
+ @since(2.5)
+ def getActiveSession(cls):
+ """
+ Returns the active SparkSession for the current thread, returned by the builder.
+ >>> s = SparkSession.getActiveSession()
+ >>> l = [('Alice', 1)]
+ >>> rdd = s.sparkContext.parallelize(l)
+ >>> df = s.createDataFrame(rdd, ['name', 'age'])
+ >>> df.select("age").collect()
+ [Row(age=1)]
+ """
+ return cls._activeSession
--- End diff --
The problem here is when we share single JVM like Zeppelin. It should get the session from JVM.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org