anishshri-db commented on code in PR #48686:
URL: https://github.com/apache/spark/pull/48686#discussion_r1821333379
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateInitialStateSuite.scala:
##########
@@ -83,6 +98,67 @@ abstract class StatefulProcessorWithInitialStateTestClass[V]
}
}
+/**
+ * Stateful processor that will take a union dataframe output from state data
source reader,
+ * with flattened state data source rows.
+ */
+class InitialStatefulProcessorWithStateDataSource
+ extends StatefulProcessorWithInitialStateTestClass[UnionInitialStateRow] {
+ override def handleInitialState(
+ key: String, initialState: UnionInitialStateRow, timerValues:
TimerValues): Unit = {
+ val stateVar = {
+ if (initialState.value.isDefined) {
+ "value"
+ }
+ else if (initialState.listValue.isDefined) {
+ "list"
+ }
+ else if (initialState.userMapKey.isDefined) {
+ "map"
+ }
+ else {
+ "invalid"
+ }
+ }
+ stateVar match {
+ case "value" => _valState.update(initialState.value.get.toDouble)
+ case "list" =>
_listState.appendValue(initialState.listValue.get.toDouble)
+ case "map" =>
+ _mapState.updateValue(
+ (initialState.userMapKey.get.charAt(0) - 'a').toDouble,
+ initialState.userMapValue.get.toInt)
+ }
+ }
+}
+
+/**
+ * Stateful processor that will take a union dataframe output from state data
source reader,
+ * with composite type state data source rows.
+ */
+class InitialStatefulProcessorWithUnflattenStateDataSource
+ extends
StatefulProcessorWithInitialStateTestClass[UnionUnflattenInitialStateRow] {
+ override def handleInitialState(
+ key: String, initialState: UnionUnflattenInitialStateRow, timerValues:
TimerValues): Unit = {
+ val stateVar = {
+ if (initialState.value.isDefined) "value"
Review Comment:
lets fix the braces here too ?
--
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]