Del via


readStream

Returns a DataStreamReader that can be used to read data streams as a streaming DataFrame.

Syntax

readStream

Returns

DataStreamReader

Examples

import time

# Use Rate source that generates rows continuously, apply modulo by 3,
# then write the stream to the console. The streaming query stops in 3 seconds.
df = spark.readStream.format("rate").load()
df = df.selectExpr("value % 3 as v")
q = df.writeStream.format("console").start()
time.sleep(3)
q.stop()