Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
done
  • Loading branch information
WweiL committed Jun 5, 2024
commit 0bc2c69d3646b77e5e5e038a9828a1937a419f26
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import scala.util.control.NonFatal

import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.scala.{ClassTagExtensions, DefaultScalaModule}
import org.json4s._
import org.json4s.JsonAST.JValue
Expand Down Expand Up @@ -204,11 +203,7 @@ private[spark] object StreamingQueryProgress {
}

private[spark] def jsonString(progress: StreamingQueryProgress): String = {
val jsonNode = mapper.valueToTree[ObjectNode](StreamingQueryProgress)
jsonNode.put("numInputRows", progress.numInputRows)
jsonNode.put("inputRowsPerSecond", progress.inputRowsPerSecond)
jsonNode.put("processedRowsPerSecond", progress.processedRowsPerSecond)
mapper.writeValueAsString(progress)
progress.json
}

private[spark] def fromJson(json: String): StreamingQueryProgress =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3259,10 +3259,6 @@ class SparkConnectPlanner(
case StreamingQueryCommand.CommandCase.LAST_PROGRESS |
StreamingQueryCommand.CommandCase.RECENT_PROGRESS =>
val progressReports = if (command.getLastProgress) {
// scalastyle:off
println("wei== sparkconnnectplanner lasprogress" + query.lastProgress)
println("wei== sparkconnnectplanner jsonString" + StreamingQueryProgress.jsonString(query.lastProgress))
// scalastyle:on
Option(query.lastProgress).toSeq
} else {
query.recentProgress.toImmutableArraySeq
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/sql/tests/streaming/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class StreamingTestsMixin:
def test_streaming_query_functions_basic(self):
df = self.spark.readStream.format("rate").option("rowsPerSecond", 10).load()
df = self.spark.readStream.format("text").load("python/test_support/sql/streaming")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just a minor fix it will make the test more stable. We call query.processAllAvailable below, which has a very small chance of being a indefinite blocking call on rate source.

query = (
df.writeStream.format("memory")
.queryName("test_streaming_query_functions_basic")
Expand Down
11 changes: 11 additions & 0 deletions python/pyspark/sql/tests/streaming/test_streaming_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ def check_sink_progress(self, progress):
self.assertTrue(isinstance(progress.numOutputRows, int))
self.assertTrue(isinstance(progress.metrics, dict))

# def test_streaming_last_progress(self):
# try:
# df = self.spark.readStream.format("text").load("python/test_support/sql/streaming")
# query = df.writeStream.format("noop").queryName("test_streaming_progress").start()
# query.processAllAvailable()
#
# progress = StreamingQueryProgress.fromJson(query.lastProgress)
# self.check_streaming_query_progress(progress, False)
# finally:
# query.stop()

# This is a generic test work for both classic Spark and Spark Connect
def test_listener_observed_metrics(self):
class MyErrorListener(StreamingQueryListener):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import scala.util.control.NonFatal

import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.scala.{ClassTagExtensions, DefaultScalaModule}
import org.json4s._
import org.json4s.JsonAST.JValue
Expand Down Expand Up @@ -188,11 +187,7 @@ private[spark] object StreamingQueryProgress {
}

private[spark] def jsonString(progress: StreamingQueryProgress): String = {
val jsonNode = mapper.valueToTree[ObjectNode](StreamingQueryProgress)
jsonNode.put("numInputRows", progress.numInputRows)
jsonNode.put("inputRowsPerSecond", progress.inputRowsPerSecond)
jsonNode.put("processedRowsPerSecond", progress.processedRowsPerSecond)
mapper.writeValueAsString(progress)
progress.json
}

private[spark] def fromJson(json: String): StreamingQueryProgress =
Expand Down