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

    https://github.com/apache/spark/pull/22295#discussion_r225667299
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -3654,6 +3654,109 @@ def test_jvm_default_session_already_set(self):
                 spark.stop()
     
     
    +class SparkSessionTests2(unittest.TestCase):
    +
    +    def test_active_session(self):
    +        spark = SparkSession.builder \
    +            .master("local") \
    +            .getOrCreate()
    +        try:
    +            activeSession = SparkSession.getActiveSession()
    +            df = activeSession.createDataFrame([(1, 'Alice')], ['age', 
'name'])
    +            self.assertEqual(df.collect(), [Row(age=1, name=u'Alice')])
    +        finally:
    +            spark.stop()
    +
    +    def test_get_active_session_when_no_active_session(self):
    +        active = SparkSession.getActiveSession()
    +        self.assertEqual(active, None)
    +        spark = SparkSession.builder \
    +            .master("local") \
    +            .getOrCreate()
    +        active = SparkSession.getActiveSession()
    +        self.assertEqual(active, spark)
    +        spark.stop()
    +        active = SparkSession.getActiveSession()
    +        self.assertEqual(active, None)
    --- End diff --
    
    Thanks @holdenk 
    I will add a test for the above comment and also add a test for your 
comment regarding
    ```
    self._jvm.SparkSession.setActiveSession(self._jsparkSession)
    ```



---

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

Reply via email to