Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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 ...>