HeartSaVioR commented on code in PR #37461:
URL: https://github.com/apache/spark/pull/37461#discussion_r943059131
##########
python/pyspark/sql/streaming/readwriter.py:
##########
@@ -1176,15 +1459,28 @@ def toTable(
Examples
--------
- >>>
sdf.writeStream.format('parquet').queryName('query').toTable('output_table')
- ... # doctest: +SKIP
-
- >>> sdf.writeStream.trigger(processingTime='5 seconds').toTable(
- ... 'output_table',
- ... queryName='that_query',
- ... outputMode="append",
- ... format='parquet',
- ... checkpointLocation='/tmp/checkpoint') # doctest: +SKIP
+ Save a data stream to a table.
+
+ >>> import tempfile
+ >>> import time
+ >>> _ = spark.sql("DROP TABLE IF EXISTS my_table2")
+ >>> with tempfile.TemporaryDirectory() as d:
+ ... # Create a table with Rate source.
+ ... q = spark.readStream.format("rate").option(
+ ... "rowsPerSecond", 10).load().writeStream.toTable(
+ ... "my_table2",
+ ... queryName='that_query',
+ ... outputMode="append",
+ ... format='parquet',
+ ... checkpointLocation=d)
+ ... time.sleep(3)
+ ... q.stop()
+ ... spark.read.table("my_table2").show()
+ ... _ = spark.sql("DROP TABLE my_table2")
+ +...---------+-----+
Review Comment:
Ah OK interesting. The format isn't intuitive but it should be OK of course
if doctest requires it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]