xuanyuanking opened a new pull request #29756:
URL: https://github.com/apache/spark/pull/29756


   ### What changes were proposed in this pull request?
   This pr aims to add a new `table` API in DataStreamReader, which is similar 
to the table API in DataFrameReader. 
   
   ### Why are the changes needed?
   Users can directly use this API to get a Streaming DataFrame on a table. 
Below is a simple example:
   
   Application 1 for initializing and starting the streaming job:
   
   ```
   val path = "/home/yuanjian.li/runtime/to_be_deleted"
   val tblName = "my_table"
   
   // Write some data to `my_table`
   spark.range(3).write.format("parquet").option("path", 
path).saveAsTable(tblName)
   
   // Read the table as a streaming source, write result to destination 
directory
   val table = spark.readStream.table(tblName)
   table.writeStream.format("parquet").option("checkpointLocation", 
"/home/yuanjian.li/runtime/to_be_deleted_ck").start("/home/yuanjian.li/runtime/to_be_deleted_2")
   ```
   
   Application 2 for appending new data:
   
   ```
   // Append new data into the path
   spark.range(5).write.format("parquet").option("path", 
"/home/yuanjian.li/runtime/to_be_deleted").mode("append").save()
   ```
   
   Check result:
   ```
   // The desitination directory should contains all written data
   spark.read.parquet("/home/yuanjian.li/runtime/to_be_deleted_2").show()
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, a new API added.
   
   ### How was this patch tested?
   New UT added and integrated testing.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to