class pyspark.sql.streaming.DataStreamReader(spark: SparkSession)[source]

Interface used to load a streaming DataFrame from external storage systems (e.g. file systems, key-value stores, etc). Use SparkSession.readStream to access this.

New in version 2.0.0.


This API is evolving.


>>> spark.readStream
<pyspark.sql.streaming.readwriter.DataStreamReader object ...>

The example below uses Rate source that generates rows continuously. After that, we operate a modulo by 3, and then writes the stream out to the console. The streaming query stops in 3 seconds.

>>> import time
>>> df = spark.readStream.format("rate").load()
>>> df = df.selectExpr("value % 3 as v")
>>> q = df.writeStream.format("console").start()
>>> time.sleep(3)
>>> q.stop()


csv(path[, schema, sep, encoding, quote, …])

Loads a CSV file stream and returns the result as a DataFrame.


Specifies the input data source format.

json(path[, schema, primitivesAsString, …])

Loads a JSON file stream and returns the results as a DataFrame.

load([path, format, schema])

Loads a data stream from a data source and returns it as a DataFrame.

option(key, value)

Adds an input option for the underlying data source.


Adds input options for the underlying data source.

orc(path[, mergeSchema, pathGlobFilter, …])

Loads a ORC file stream, returning the result as a DataFrame.

parquet(path[, mergeSchema, pathGlobFilter, …])

Loads a Parquet file stream, returning the result as a DataFrame.


Specifies the input schema.


Define a Streaming DataFrame on a Table.

text(path[, wholetext, lineSep, …])

Loads a text file stream and returns a DataFrame whose schema starts with a string column named “value”, and followed by partitioned columns if there are any.