Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22295#discussion_r222958780
  
    --- 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 --
    
    Yup.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to