jingz-db commented on code in PR #48290:
URL: https://github.com/apache/spark/pull/48290#discussion_r1797236511
##########
python/pyspark/sql/streaming/stateful_processor.py:
##########
@@ -121,6 +126,83 @@ def clear(self) -> None:
self._list_state_client.clear(self._state_name)
+class MapState:
+ """
+ Class used for arbitrary stateful operations with transformWithState to
capture single map
+ state.
+
+ .. versionadded:: 4.0.0
+ """
+
+ def __init__(
+ self,
+ map_state_client: MapStateClient,
+ state_name: str,
+ key_schema: Union[StructType, str],
+ value_schema: Union[StructType, str],
+ ) -> None:
+ self._map_state_client = map_state_client
+ self._state_name = state_name
+ self.key_schema = key_schema
+ self.value_schema = value_schema
+
+ def exists(self) -> bool:
+ """
+ Whether state exists or not.
+ """
+ return self._map_state_client.exists(self._state_name)
+
+ def get_value(self, key: Tuple) -> Optional[Tuple]:
Review Comment:
Makes sense. We should couple with Scala API. Let's keep the way it is.
Thanks for checking!
--
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]