Skip to content

Commit ac9009f

Browse files
committed
Add a test for metrics
1 parent 50cf3e6 commit ac9009f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/ForeachSinkSuite.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,21 @@ class ForeachSinkSuite extends StreamTest with SharedSQLContext with BeforeAndAf
253253
query.stop()
254254
}
255255
}
256+
257+
test("foreach sink should support metrics") {
258+
val inputData = MemoryStream[Int]
259+
val query = inputData.toDS()
260+
.writeStream
261+
.foreach(new TestForeachWriter())
262+
.start()
263+
try {
264+
inputData.addData(10, 11, 12)
265+
query.processAllAvailable()
266+
assert(query.lastProgress.numInputRows === 3)
267+
} finally {
268+
query.stop()
269+
}
270+
}
256271
}
257272

258273
/** A global object to collect events in the executor */

0 commit comments

Comments
 (0)