code: def test_stream_exception(self):
      sdf = self.spark.readStream.format("text").load(
          "python/test_support/sql/streaming"
      )
      sq = (
          sdf.writeStream.format("memory")
          .queryName("query_explain")
          .start()
      )
      try:
          sq.processAllAvailable()
          self.assertEqual(sq.exception(), None)
      finally:
          sq.stop()
  
      from pyspark.sql.functions import col, udf
      from pyspark.errors import StreamingQueryException
  
      bad_udf = udf(lambda x: 1 / 0)
      sq = (
          sdf.select(bad_udf(col("value")))
          .writeStream.format("memory")
          .queryName("this_query")
          .start()
      )
      try:
          # Process some data to fail the query
          sq.processAllAvailable()
          self.fail("bad udf should fail the query")
      except StreamingQueryException as e:
          # This is expected
          self._assert_exception_tree_contains_msg(
              e, "ZeroDivisionError"
          )
      finally:
          exception = sq.exception()
          sq.stop()
      self.assertIsInstance(exception, StreamingQueryException)
      self._assert_exception_tree_contains_msg(
          exception, "ZeroDivisionError"
      )
  
imports: import os
  import shutil
  import tempfile
  import time
  from pyspark.sql import Row
  from pyspark.sql.functions import lit
  from pyspark.sql.types import StructType, StructField, IntegerType, StringType
  from pyspark.testing.sqlutils import ReusedSQLTestCase
label_desc: Use image node_id 9 for calling the StreamingTestsMixin obj's underlying member method code with example usage: obj.test_stream_exception() without return types