jingz-db commented on code in PR #48686:
URL: https://github.com/apache/spark/pull/48686#discussion_r1830096213


##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateInitialStateSuite.scala:
##########
@@ -83,6 +98,49 @@ 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 = {
+    if (initialState.value.isDefined) {
+      _valState.update(initialState.value.get.toDouble)
+    } else if (initialState.listValue.isDefined) {
+      _listState.appendValue(initialState.listValue.get.toDouble)
+    } else if (initialState.userMapKey.isDefined) {
+      _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.

Review Comment:
   Done. Modified handle initial state to be simply put the values in the 
initialState dataframe into state variables.



-- 
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]

Reply via email to