Skip to content

Commit

Permalink
[SPARK-48567][PYTHON][TESTS][FOLLOW-UP] Make the query scope higher s…
Browse files Browse the repository at this point in the history
…o finally can access to it

### What changes were proposed in this pull request?

This PR is a followup that fixes the test to recover the build.

### Why are the changes needed?

To fix up the build.

### Does this PR introduce _any_ user-facing change?

No, test-only.

### How was this patch tested?

CI in this PR.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #48417 from HyukjinKwon/SPARK-48567-followup.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
  • Loading branch information
HyukjinKwon committed Oct 11, 2024
1 parent 2af6536 commit 4666972
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/pyspark/sql/tests/streaming/test_streaming_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def onQueryIdle(self, event):
def onQueryTerminated(self, event):
pass

q = None
try:
error_listener = MyErrorListener()
self.spark.streams.addListener(error_listener)
Expand All @@ -238,10 +239,12 @@ def onQueryTerminated(self, event):
self.assertTrue(error_listener.num_error_rows > 0)

finally:
q.stop()
if q is not None:
q.stop()
self.spark.streams.removeListener(error_listener)

def test_streaming_progress(self):
q = None
try:
# Test a fancier query with stateful operation and observed metrics
df = self.spark.readStream.format("rate").option("rowsPerSecond", 10).load()
Expand All @@ -265,7 +268,8 @@ def test_streaming_progress(self):
self.check_streaming_query_progress(p, True)

finally:
q.stop()
if q is not None:
q.stop()


class StreamingListenerTests(StreamingListenerTestsMixin, ReusedSQLTestCase):
Expand Down

0 comments on commit 4666972

Please sign in to comment.