HyukjinKwon commented on code in PR #46189:
URL: https://github.com/apache/spark/pull/46189#discussion_r1577575597
##########
python/pyspark/sql/dataframe.py:
##########
@@ -4671,13 +4672,20 @@ def observe(
... def onQueryTerminated(self, event):
... pass
...
- >>> spark.streams.addListener(MyErrorListener())
+ >>> error_listener = MyErrorListener()
+ >>> spark.streams.addListener(error_listener)
+ >>> sdf = spark.readStream.format("rate").load().withColumn(
+ ... "error", col("value")
+ ... )
>>> # Observe row count (rc) and error row count (erc) in the
streaming Dataset
- ... observed_ds = df.observe(
+ ... observed_ds = sdf.observe(
... "my_event",
... count(lit(1)).alias("rc"),
- ... count(col("error")).alias("erc")) # doctest: +SKIP
- >>> observed_ds.writeStream.format("console").start() # doctest: +SKIP
+ ... count(col("error")).alias("erc"))
+ >>> q = observed_ds.writeStream.format("console").start()
+ >>> time.sleep(5)
+ >>> q.stop()
Review Comment:
Actually shall we put this in finally
--
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]