grundprinzip commented on code in PR #46002:
URL: https://github.com/apache/spark/pull/46002#discussion_r1561624955


##########
python/pyspark/sql/connect/streaming/readwriter.py:
##########
@@ -535,14 +535,16 @@ def foreach(self, f: "SupportsProcess") -> 
"DataStreamWriter":
 
     def foreach(self, f: Union[Callable[[Row], None], "SupportsProcess"]) -> 
"DataStreamWriter":
         from pyspark.serializers import CPickleSerializer, 
AutoBatchedSerializer
+        from pyspark.sql.connect.session import SparkSession
 
         func = PySparkDataStreamWriter._construct_foreach_function(f)
         serializer = AutoBatchedSerializer(CPickleSerializer())
         command = (func, None, serializer, serializer)
+        dispatch_handlers = {SparkSession: lambda x: 
x.__custom_reduce_handler__()}
         # Python ForeachWriter isn't really a PythonUDF. But we reuse it for 
simplicity.
         try:
             self._write_proto.foreach_writer.python_function.command = (
-                CloudPickleSerializer().dumps(command)
+                CloudPickleSerializer().dumps(command, 
dispatch_handlers=dispatch_handlers)

Review Comment:
   Done



##########
python/pyspark/sql/connect/streaming/readwriter.py:
##########
@@ -535,14 +535,16 @@ def foreach(self, f: "SupportsProcess") -> 
"DataStreamWriter":
 
     def foreach(self, f: Union[Callable[[Row], None], "SupportsProcess"]) -> 
"DataStreamWriter":
         from pyspark.serializers import CPickleSerializer, 
AutoBatchedSerializer
+        from pyspark.sql.connect.session import SparkSession
 
         func = PySparkDataStreamWriter._construct_foreach_function(f)
         serializer = AutoBatchedSerializer(CPickleSerializer())
         command = (func, None, serializer, serializer)
+        dispatch_handlers = {SparkSession: lambda x: 
x.__custom_reduce_handler__()}
         # Python ForeachWriter isn't really a PythonUDF. But we reuse it for 
simplicity.
         try:
             self._write_proto.foreach_writer.python_function.command = (
-                CloudPickleSerializer().dumps(command)
+                CloudPickleSerializer().dumps(command, 
dispatch_handlers=dispatch_handlers)

Review Comment:
   Removed the handlers



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to