HeartSaVioR commented on code in PR #47933:
URL: https://github.com/apache/spark/pull/47933#discussion_r1770700243
##########
python/pyspark/sql/streaming/stateful_processor.py:
##########
@@ -77,6 +78,58 @@ def clear(self) -> None:
self._value_state_client.clear(self._state_name)
+class ListState:
+ """
+ Class used for arbitrary stateful operations with transformWithState to
capture single value
+ state.
+
+ .. versionadded:: 4.0.0
+ """
+
+ def __init__(
+ self, list_state_client: ListStateClient, state_name: str, schema:
Union[StructType, str]
+ ) -> None:
+ self._list_state_client = list_state_client
+ self._state_name = state_name
+ self.schema = schema
+
+ def exists(self) -> bool:
+ """
+ Whether list state exists or not.
+ """
+ return self._list_state_client.exists(self._state_name)
+
+ def get(self) -> Iterator[Row]:
+ """
+ Get list state with an iterator.
+ """
+ return ListStateIterator(self._list_state_client, self._state_name)
+
+ def put(self, new_state: List[Any]) -> None:
Review Comment:
Yeah good to be consistent and Tuple is stricter (more helpful).
--
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]