You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ka...@apache.org on 2024/12/14 01:57:05 UTC
(spark) branch master updated: [SPARK-50565][SS][TESTS] Add transformWithState correctness test
This is an automated email from the ASF dual-hosted git repository.
kabhwan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new f8de6c7b74b8 [SPARK-50565][SS][TESTS] Add transformWithState correctness test
f8de6c7b74b8 is described below
commit f8de6c7b74b895e0fa00a678120dd64c3aa1db3d
Author: Wei Liu <we...@databricks.com>
AuthorDate: Sat Dec 14 10:56:51 2024 +0900
[SPARK-50565][SS][TESTS] Add transformWithState correctness test
### What changes were proposed in this pull request?
As title
### Why are the changes needed?
Test coverage
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Test only addition
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #49173 from WweiL/tws-followup.
Authored-by: Wei Liu <we...@databricks.com>
Signed-off-by: Jungtaek Lim <ka...@gmail.com>
---
.../RocksDBStateStoreCheckpointFormatV2Suite.scala | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreCheckpointFormatV2Suite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreCheckpointFormatV2Suite.scala
index 24c99bffd8ba..5725ebaf727b 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreCheckpointFormatV2Suite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreCheckpointFormatV2Suite.scala
@@ -542,4 +542,35 @@ class RocksDBStateStoreCheckpointFormatV2Suite extends StreamTest
}
validateCheckpointInfo(6, 1, Set(2, 4, 6))
}
+
+ test("checkpointFormatVersion2 validate transformWithState") {
+ withTempDir { checkpointDir =>
+ val inputData = MemoryStream[String]
+ val result = inputData.toDS()
+ .groupByKey(x => x)
+ .transformWithState(new RunningCountStatefulProcessor(),
+ TimeMode.None(),
+ OutputMode.Update())
+
+ testStream(result, Update())(
+ StartStream(checkpointLocation = checkpointDir.getAbsolutePath),
+ AddData(inputData, "a"),
+ CheckNewAnswer(("a", "1")),
+ Execute { q =>
+ assert(q.lastProgress.stateOperators(0).customMetrics.get("numValueStateVars") > 0)
+ assert(q.lastProgress.stateOperators(0).customMetrics.get("numRegisteredTimers") == 0)
+ },
+ AddData(inputData, "a", "b"),
+ CheckNewAnswer(("a", "2"), ("b", "1")),
+ StopStream,
+ StartStream(checkpointLocation = checkpointDir.getAbsolutePath),
+ AddData(inputData, "a", "b"), // should remove state for "a" and not return anything for a
+ CheckNewAnswer(("b", "2")),
+ StopStream,
+ StartStream(checkpointLocation = checkpointDir.getAbsolutePath),
+ AddData(inputData, "a", "c"), // should recreate state for "a" and return count as 1 and
+ CheckNewAnswer(("a", "1"), ("c", "1"))
+ )
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org