rangadi commented on code in PR #40887:
URL: https://github.com/apache/spark/pull/40887#discussion_r1173103492
##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/streaming/StreamingQuerySuite.scala:
##########
@@ -78,4 +78,44 @@ class StreamingQuerySuite extends RemoteSparkSession with
SQLHelper {
}
}
}
+
+ test("Streaming table API") {
+ withSQLConf(
+ "spark.sql.shuffle.partitions" -> "1" // Avoid too many reducers.
+ ) {
+ spark.sql("DROP TABLE IF EXISTS my_table")
+
+ withTempPath {
+ ckpt =>
+ val q1 = spark.readStream
+ .format("rate")
+ .load()
+ .writeStream
+ .option("checkpointLocation", ckpt.getCanonicalPath)
+ .toTable("my_table")
+
+ val q2 = spark.readStream
+ .table("my_table")
+ .writeStream
+ .format("memory")
+ .queryName("my_sink")
+ .start()
+
+ try {
+ q1.processAllAvailable()
+ q2.processAllAvailable()
+ eventually(timeout(10.seconds)) {
+ assert(q2.recentProgress.nonEmpty) // Query made progress.
Review Comment:
This does not mean if would have processed any data, right? We could move
`assert(spark.table("my_sink").count() > 0)` also into this.
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/streaming/DataStreamReader.scala:
##########
@@ -217,6 +217,20 @@ final class DataStreamReader private[sql] (sparkSession:
SparkSession) extends L
*/
def parquet(path: String): DataFrame = format("parquet").load(path)
+ /**
+ * Define a Streaming DataFrame on a Table. The DataSource corresponding to
the table should
+ * support streaming mode.
+ * @param tableName The name of the table
+ * @since 3.5.0
+ */
+ def table(tableName: String): DataFrame = {
+ require(tableName != null, "The table name can't be null")
+ sparkSession.newDataFrame { builder =>
+ builder.getReadBuilder.setIsStreaming(true).getNamedTableBuilder
Review Comment:
Need set options.
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/streaming/DataStreamReader.scala:
##########
@@ -217,6 +217,20 @@ final class DataStreamReader private[sql] (sparkSession:
SparkSession) extends L
*/
def parquet(path: String): DataFrame = format("parquet").load(path)
+ /**
+ * Define a Streaming DataFrame on a Table. The DataSource corresponding to
the table should
+ * support streaming mode.
+ * @param tableName The name of the table
+ * @since 3.5.0
+ */
+ def table(tableName: String): DataFrame = {
+ require(tableName != null, "The table name can't be null")
+ sparkSession.newDataFrame { builder =>
+ builder.getReadBuilder.setIsStreaming(true).getNamedTableBuilder
Review Comment:
Need to set options.
--
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]