code: def test_streaming_foreach_batch_propagates_python_errors(self):
      from pyspark.errors import StreamingQueryException
  
      q = None
  
      def collectBatch(df, id):
          raise RuntimeError("this should fail the query")
  
      try:
          df = self.spark.readStream.format("text").load(
              "python/test_support/sql/streaming"
          )
          q = df.writeStream.foreachBatch(collectBatch).start()
          q.processAllAvailable()
          self.fail("Expected a failure")
      except StreamingQueryException as e:
          self.assertTrue("this should fail" in str(e))
      finally:
          if q:
              q.stop()
  
file_path: spark/python/pyspark/sql/tests/streaming/test_streaming_foreach_batch.py
imports: import time
  from pyspark.sql.dataframe import DataFrame
  from pyspark.testing.sqlutils import ReusedSQLTestCase
label_desc: Use image node_id 3 for calling the StreamingTestsForeachBatchMixin obj's underlying member method code with example usage: obj.test_streaming_foreach_batch_propagates_python_errors() without return types