Skip to content

Commit 57bc1e9

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.
1 parent c26976f commit 57bc1e9

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
@@ -2619,8 +2619,12 @@ def test_sparksession_with_stopped_sparkcontext(self):
26192619
self.sc.stop()
26202620
sc = SparkContext('local[4]', self.sc.appName)
26212621
spark = SparkSession.builder.getOrCreate()
2622-
df = spark.createDataFrame([(1, 2)], ["c", "c"])
2623-
df.collect()
2622+
try:
2623+
df = spark.createDataFrame([(1, 2)], ["c", "c"])
2624+
df.collect()
2625+
finally:
2626+
spark.stop()
2627+
sc.stop()
26242628

26252629

26262630
class UDFInitializationTests(unittest.TestCase):

0 commit comments

Comments
 (0)