Skip to content

Commit 4304d0b

Browse files
committed
[SPARK-21950][SQL][PYTHON][TEST] pyspark.sql.tests.SQLTests2 should stop SparkContext.
## What changes were proposed in this pull request? `pyspark.sql.tests.SQLTests2` doesn't stop newly created spark context in the test and it might affect the following tests. This pr makes `pyspark.sql.tests.SQLTests2` stop `SparkContext`. ## How was this patch tested? Existing tests. Author: Takuya UESHIN <[email protected]> Closes #19158 from ueshin/issues/SPARK-21950. (cherry picked from commit 57bc1e9) Signed-off-by: Takuya UESHIN <[email protected]>
1 parent 0848df1 commit 4304d0b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/pyspark/sql/tests.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,12 @@ def test_sparksession_with_stopped_sparkcontext(self):
22522252
self.sc.stop()
22532253
sc = SparkContext('local[4]', self.sc.appName)
22542254
spark = SparkSession.builder.getOrCreate()
2255-
df = spark.createDataFrame([(1, 2)], ["c", "c"])
2256-
df.collect()
2255+
try:
2256+
df = spark.createDataFrame([(1, 2)], ["c", "c"])
2257+
df.collect()
2258+
finally:
2259+
spark.stop()
2260+
sc.stop()
22572261

22582262

22592263
class UDFInitializationTests(unittest.TestCase):

0 commit comments

Comments
 (0)