format (DataStreamWriter)

基になる出力データ ソースを指定します。

構文

format(source)

パラメーター

パラメーター タイプ 説明
source str データ ソースの名前 ( 'parquet''console'など)。

返品

DataStreamWriter

例示

df = spark.readStream.format("rate").load()
df.writeStream.format("text")
# <...streaming.readwriter.DataStreamWriter object ...>

レート ソース ストリームを CSV に書き込みます。

import tempfile
import time
with tempfile.TemporaryDirectory(prefix="format1") as d:
    with tempfile.TemporaryDirectory(prefix="format2") as cp:
        df = spark.readStream.format("rate").load()
        q = df.writeStream.format("csv").option("checkpointLocation", cp).start(d)
        time.sleep(5)
        q.stop()
        spark.read.schema("timestamp TIMESTAMP, value STRING").csv(d).show()