brijrajk commented on code in PR #56473: URL: https://github.com/apache/spark/pull/56473#discussion_r3461276411
########## python/docs/source/tutorial/sql/python_data_source.rst: ########## @@ -388,6 +388,50 @@ This is useful for: For a complete working example, see: ``examples/src/main/python/sql/streaming/structured_blockchain_admission_control.py`` +Supporting Trigger.AvailableNow +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Trigger.AvailableNow`` processes all data available at query start time, then +terminates, which is useful for scheduled batch-style runs over a streaming source. + +To support it, mix in :class:`~pyspark.sql.streaming.datasource.SupportsTriggerAvailableNow` +and implement ``prepareForTriggerAvailableNow()``. Spark calls this method once at +query start so the reader can record the target offset (the latest offset at that +moment). Subsequent calls to ``latestOffset()`` must not return an offset beyond +that target, so that the query eventually terminates. + +.. code-block:: python + + from pyspark.sql.streaming.datasource import ( + DataSourceStreamReader, + ReadLimit, + SupportsTriggerAvailableNow, + ) Review Comment: Fixed, split into two imports: `DataSourceStreamReader` from `pyspark.sql.datasource` and `ReadLimit`, `SupportsTriggerAvailableNow` from `pyspark.sql.streaming.datasource`. Thanks! -- 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]
