-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-48755][SS][PYTHON] transformWithState pyspark base implementation and ValueState support #47133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-48755][SS][PYTHON] transformWithState pyspark base implementation and ValueState support #47133
Changes from 1 commit
b1175e4
0a98ed8
8e2b193
16e4c17
92ef716
c3eaf38
609d94e
a27f9d9
684939b
7f65fbd
c25d7da
9c8c616
c641192
8d3da4e
cc9bf95
f7df2dc
27cd169
3b5b3e5
5d910d8
df859ab
654f2f6
38832a6
0585ac0
0ee5029
6232c81
41f8234
d57633f
df9ea9e
68f7a7e
ca5216b
c9e3a7c
2320805
6e5de2e
200ec5e
dd3e46b
e8360d4
82983af
49dbc16
d4e04ea
e108f60
bae26c2
d96fa9e
92531db
d507793
5dcb4c8
37be02a
f63687f
263c087
c7b0a4f
c80b292
81276f3
5886b5c
23e54b4
2ba4fd0
2a9c20b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ def __init__( | |
| # place holder, will remove when actual implementation is done | ||
| # self.setHandleState(StatefulProcessorHandleState.CLOSED) | ||
|
|
||
| def setHandleState(self, state: StatefulProcessorHandleState) -> None: | ||
| def set_handle_state(self, state: StatefulProcessorHandleState) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add like 1-2 line comments for these functions ? |
||
| print(f"setting handle state to: {state}") | ||
| proto_state = self._get_proto_state(state) | ||
| set_handle_state = stateMessage.SetHandleState(state=proto_state) | ||
|
|
@@ -60,7 +60,7 @@ def setHandleState(self, state: StatefulProcessorHandleState) -> None: | |
| self.handle_state = state | ||
| print(f"setHandleState status= {status}") | ||
|
|
||
| def getValueState(self, state_name: str, schema: Union[StructType, str]) -> None: | ||
| def get_value_state(self, state_name: str, schema: Union[StructType, str]) -> None: | ||
| if isinstance(schema, str): | ||
| schema = cast(StructType, _parse_datatype_string(schema)) | ||
|
|
||
|
|
@@ -77,7 +77,7 @@ def getValueState(self, state_name: str, schema: Union[StructType, str]) -> None | |
| status = read_int(self.sockfile) | ||
| print(f"getValueState status= {status}") | ||
|
|
||
| def valueStateExists(self, state_name: str) -> bool: | ||
| def value_state_exists(self, state_name: str) -> bool: | ||
| print(f"checking value state exists: {state_name}") | ||
| exists_call = stateMessage.Exists(stateName=state_name) | ||
| value_state_call = stateMessage.ValueStateCall(exists=exists_call) | ||
|
|
@@ -92,7 +92,7 @@ def valueStateExists(self, state_name: str) -> bool: | |
| else: | ||
| return False | ||
|
|
||
| def valueStateGet(self, state_name: str) -> Any: | ||
| def value_state_get(self, state_name: str) -> Any: | ||
| print(f"getting value state: {state_name}") | ||
| get_call = stateMessage.Get(stateName=state_name) | ||
| value_state_call = stateMessage.ValueStateCall(get=get_call) | ||
|
|
@@ -107,7 +107,7 @@ def valueStateGet(self, state_name: str) -> Any: | |
| else: | ||
| return None | ||
|
|
||
| def valueStateUpdate(self, state_name: str, schema: Union[StructType, str], value: str) -> None: | ||
| def value_state_update(self, state_name: str, schema: Union[StructType, str], value: str) -> None: | ||
| if isinstance(schema, str): | ||
| schema = cast(StructType, _parse_datatype_string(schema)) | ||
| print(f"updating value state: {state_name}") | ||
|
|
@@ -121,7 +121,7 @@ def valueStateUpdate(self, state_name: str, schema: Union[StructType, str], valu | |
| status = read_int(self.sockfile) | ||
| print(f"valueStateUpdate status= {status}") | ||
|
|
||
| def valueStateClear(self, state_name: str) -> None: | ||
| def value_state_clear(self, state_name: str) -> None: | ||
| print(f"clearing value state: {state_name}") | ||
| clear_call = stateMessage.Clear(stateName=state_name) | ||
| value_state_call = stateMessage.ValueStateCall(clear=clear_call) | ||
|
|
@@ -132,22 +132,7 @@ def valueStateClear(self, state_name: str) -> None: | |
| status = read_int(self.sockfile) | ||
| print(f"valueStateClear status= {status}") | ||
|
|
||
| def getListState(self, state_name: str, schema: Union[StructType, str]) -> None: | ||
| if isinstance(schema, str): | ||
| schema = cast(StructType, _parse_datatype_string(schema)) | ||
|
|
||
| state_call_command = stateMessage.StateCallCommand() | ||
| state_call_command.stateName = state_name | ||
| state_call_command.schema = schema.json() | ||
| call = stateMessage.StatefulProcessorCall(getListState=state_call_command) | ||
|
|
||
| message = stateMessage.StateRequest(statefulProcessorCall=call) | ||
|
|
||
| self._send_proto_message(message) | ||
| status = read_int(self.sockfile) | ||
| print(f"status= {status}") | ||
|
|
||
| def setImplicitKey(self, key: str) -> None: | ||
| def set_implicit_key(self, key: str) -> None: | ||
| print(f"setting implicit key: {key}") | ||
| set_implicit_key = stateMessage.SetImplicitKey(key=key) | ||
| request = stateMessage.ImplicitGroupingKeyRequest(setImplicitKey=set_implicit_key) | ||
|
|
@@ -157,7 +142,7 @@ def setImplicitKey(self, key: str) -> None: | |
| status = read_int(self.sockfile) | ||
| print(f"setImplicitKey status= {status}") | ||
|
|
||
| def removeImplicitKey(self) -> None: | ||
| def remove_implicit_key(self) -> None: | ||
| print(f"removing implicit key") | ||
| remove_implicit_key = stateMessage.RemoveImplicitKey() | ||
| request = stateMessage.ImplicitGroupingKeyRequest(removeImplicitKey=remove_implicit_key) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,16 +35,16 @@ def __init__(self, | |
| self.schema = schema | ||
|
|
||
| def exists(self) -> bool: | ||
| return self._state_api_client.valueStateExists(self._state_name) | ||
| return self._state_api_client.value_state_exists(self._state_name) | ||
|
|
||
| def get(self) -> Any: | ||
|
||
| return self._state_api_client.valueStateGet(self._state_name) | ||
| return self._state_api_client.value_state_get(self._state_name) | ||
|
|
||
| def update(self, new_value: Any) -> None: | ||
| self._state_api_client.valueStateUpdate(self._state_name, self.schema, new_value) | ||
| self._state_api_client.value_state_update(self._state_name, self.schema, new_value) | ||
|
|
||
| def clear(self) -> None: | ||
| self._state_api_client.valueStateClear(self._state_name) | ||
| self._state_api_client.value_state_clear(self._state_name) | ||
|
|
||
|
|
||
| class ListState: | ||
bogao007 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -74,7 +74,7 @@ def __init__( | |
| self.state_api_client = state_api_client | ||
|
|
||
| def getValueState(self, state_name: str, schema: Union[StructType, str]) -> ValueState: | ||
| self.state_api_client.getValueState(state_name, schema) | ||
| self.state_api_client.get_value_state(state_name, schema) | ||
| return ValueState(self.state_api_client, state_name, schema) | ||
|
|
||
| def getListState(self, state_name: str, schema: Union[StructType, str]) -> ListState: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.