將 DataFrame 的內容串流到資料來源,並回傳 StreamingQuery 物件。
語法
start(path=None, format=None, outputMode=None, partitionBy=None, queryName=None, **options)
參數
| 參數 | 類型 | 說明 |
|---|---|---|
path |
力量,選用 | Hadoop 支援的檔案系統中的路徑。 |
format |
力量,選用 | 過去的格式是用來儲存的。 |
outputMode |
力量,選用 | 資料如何寫入匯流: append、、 complete或 update。 |
partitionBy |
力量或列表,選擇性 | 分割欄位名稱。 |
queryName |
力量,選用 | 查詢名稱獨特。 |
**options |
其他所有弦線選項。 提供 checkpointLocation 大多數溪流;溪流並非必需 memory 。 |
退貨
StreamingQuery
Examples
df = spark.readStream.format("rate").load()
基本例子:
q = df.writeStream.format('memory').queryName('this_query').start()
q.isActive
# True
q.name
# 'this_query'
q.stop()
q.isActive
# False
配備觸發器及額外參數:
q = df.writeStream.trigger(processingTime='5 seconds').start(
queryName='that_query', outputMode="append", format='memory')
q.name
# 'that_query'
q.isActive
# True
q.stop()