You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ueshin (via GitHub)" <gi...@apache.org> on 2023/07/26 20:20:31 UTC

[GitHub] [spark] ueshin commented on a diff in pull request #42116: [SPARK-42941][SS][CONNECT] Python StreamingQueryListener

ueshin commented on code in PR #42116:
URL: https://github.com/apache/spark/pull/42116#discussion_r1275445150


##########
python/pyspark/sql/connect/streaming/query.py:
##########
@@ -230,21 +233,26 @@ def resetTerminated(self) -> None:
 
     resetTerminated.__doc__ = PySparkStreamingQueryManager.resetTerminated.__doc__
 
-    def addListener(self, listener: Any) -> None:
-        # TODO(SPARK-42941): Change listener type to Connect StreamingQueryListener
-        # and implement below
-        raise NotImplementedError("addListener() is not implemented.")
+    def addListener(self, listener: StreamingQueryListener) -> None:
+        listener._init_listener_id()
+        cmd = pb2.StreamingQueryManagerCommand()
+        expr = proto.PythonUDF()
+        expr.command = CloudPickleSerializer().dumps(listener)
+        expr.python_ver = "%d.%d" % sys.version_info[:2]
+        cmd.add_listener.python_listener_payload.CopyFrom(expr)
+        cmd.add_listener.id = listener._id
+        self._execute_streaming_query_manager_cmd(cmd)
+        return None

Review Comment:
   We can omit `return None` (or `return`) when the return type is `None`.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org