Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sets the trigger for the streaming query. If not set, the query runs as fast as possible, equivalent to processingTime='0 seconds'. Only one trigger parameter can be set at a time.
For more information, see Configure Structured Streaming trigger intervals.
Syntax
trigger(*, processingTime=None, once=None, continuous=None, availableNow=None, realTime=None)
Parameters
| Parameter | Type | Description |
|---|---|---|
processingTime |
str, optional | A processing time interval string (for example, '5 seconds', '1 minute'). Runs a microbatch query periodically based on the processing time. |
once |
bool, optional | If True, processes only one batch of data then terminates the query. |
continuous |
str, optional | A time interval string (for example, '5 seconds'). Runs a continuous query with a given checkpoint interval. |
availableNow |
bool, optional | If True, processes all available data in multiple batches then terminates the query. |
realTime |
str, optional | A batch duration string (for example, '5 seconds'). Runs a real-time mode query with batches at the specified duration. |
Returns
DataStreamWriter
Examples
df = spark.readStream.format("rate").load()
Trigger execution every 5 seconds:
df.writeStream.trigger(processingTime='5 seconds')
# <...streaming.readwriter.DataStreamWriter object ...>
Trigger continuous execution every 5 seconds:
df.writeStream.trigger(continuous='5 seconds')
# <...streaming.readwriter.DataStreamWriter object ...>
Process all available data in multiple batches:
df.writeStream.trigger(availableNow=True)
# <...streaming.readwriter.DataStreamWriter object ...>
Trigger real-time execution every 5 seconds:
df.writeStream.trigger(realTime='5 seconds')
# <...streaming.readwriter.DataStreamWriter object ...>