Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix test
  • Loading branch information
JoshRosen committed Apr 4, 2024
commit ce7580f3d838f6a5f5fd6927719855e53b3cd41c
6 changes: 5 additions & 1 deletion python/pyspark/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,19 @@ def writeStream(self) -> DataStreamWriter:

Examples
--------
>>> import time
>>> import tempfile
>>> df = spark.readStream.format("rate").load()
>>> type(df.writeStream)
<class '...streaming.readwriter.DataStreamWriter'>

>>> with tempfile.TemporaryDirectory(prefix="writeStream") as d:
... # Create a table with Rate source.
... df.writeStream.toTable(
... query = df.writeStream.toTable(
... "my_table", checkpointLocation=d)
... print(type(query))
... time.sleep(3)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied this from

>>> query = (df
... .withWatermark("timestamp", "10 minutes")
... .groupBy(
... window(df.timestamp, "10 minutes", "5 minutes"),
... df.value)
... ).count().writeStream.outputMode("complete").format("console").start()
>>> time.sleep(3)
>>> query.stop()

... query.stop()
<...streaming.query.StreamingQuery object at 0x...>
"""
return DataStreamWriter(self)
Expand Down