pyspark.sql.DataFrame.writeStream

property DataFrame.writeStream

Interface for saving the content of the streaming DataFrame out into external storage.

New in version 2.0.0.

Returns
DataStreamWriter

Notes

This API is evolving.

Examples

>>> import tempfile
>>> df = spark.readStream.format("rate").load()
>>> type(df.writeStream)
<class 'pyspark.sql.streaming.readwriter.DataStreamWriter'>
>>> with tempfile.TemporaryDirectory() as d:
...     # Create a table with Rate source.
...     df.writeStream.toTable(
...         "my_table", checkpointLocation=d) 
<pyspark.sql.streaming.query.StreamingQuery object at 0x...>