メインコンテンツまでスキップ

開始(DataStreamWriter)

DataFrameの内容をデータ ソースにストリームし、StreamingQuery オブジェクトを返します。

構文

start(path=None, format=None, outputMode=None, partitionBy=None, queryName=None, **options)

パラメーター

パラメーター

Type

説明

path

文字列、オプション

Hadoopがサポートするファイルシステム内のパス。

format

文字列、オプション

保存に使用されるフォーマット。

outputMode

文字列、オプション

シンクへのデータの書き込み方法: appendcomplete 、またはupdate

partitionBy

文字列またはリスト(省略可能)

パーティショニング列の名前。

queryName

文字列、オプション

クエリの一意の名前。

**options

-

その他の文字列オプション。ほとんどのストリームにはcheckpointLocation指定します。 memoryストリームには必要ありません。

戻り値

StreamingQuery

Python
df = spark.readStream.format("rate").load()

基本的な例:

Python
q = df.writeStream.format('memory').queryName('this_query').start()
q.isActive
# True
q.name
# 'this_query'
q.stop()
q.isActive
# False

トリガーと追加の懸念:

Python
q = df.writeStream.trigger(processingTime='5 seconds').start(
queryName='that_query', outputMode="append", format='memory')
q.name
# 'that_query'
q.isActive
# True
q.stop()
このページの見出し