code: def test_accessing_spark_session_through_df(self):
      dataframe = self.spark.createDataFrame(
          [("do", "not"), ("serialize", "dataframe")]
      )
  
      def func(df, _):
          dataframe.collect()
  
      error_thrown = False
      try:
          self.spark.readStream.format(
              "rate"
          ).load().writeStream.foreachBatch(func).start()
      except PySparkPicklingError as e:
          self.assertEqual(
              e.getErrorClass(), "STREAMING_CONNECT_SERIALIZATION_ERROR"
          )
          error_thrown = True
      self.assertTrue(error_thrown)
  
file_path: spark/python/pyspark/sql/tests/connect/streaming/test_parity_foreach_batch.py
imports: import unittest
  from pyspark.sql.tests.streaming.test_streaming_foreach_batch import StreamingTestsForeachBatchMixin
  from pyspark.testing.connectutils import ReusedConnectTestCase
  from pyspark.errors import PySparkPicklingError
label_desc: Use image node_id 4 for calling the StreamingForeachBatchParityTests obj's underlying member method code with example usage: obj.test_accessing_spark_session_through_df() without return types