jingz-db commented on code in PR #48005:
URL: https://github.com/apache/spark/pull/48005#discussion_r1799926038
##########
python/pyspark/sql/pandas/group_ops.py:
##########
@@ -505,22 +514,75 @@ def transformWithStateUDF(
return result
- if isinstance(outputStructType, str):
- outputStructType = cast(StructType,
_parse_datatype_string(outputStructType))
+ def transformWithStateWithInitStateUDF(
+ statefulProcessorApiClient: StatefulProcessorApiClient,
+ key: Any,
+ inputRows: Iterator["PandasDataFrameLike"],
+ # for non first batch, initialStates will be None
Review Comment:
Added the above in the comments with other input combinations.
##########
python/pyspark/sql/pandas/group_ops.py:
##########
@@ -505,22 +514,75 @@ def transformWithStateUDF(
return result
- if isinstance(outputStructType, str):
- outputStructType = cast(StructType,
_parse_datatype_string(outputStructType))
+ def transformWithStateWithInitStateUDF(
+ statefulProcessorApiClient: StatefulProcessorApiClient,
+ key: Any,
+ inputRows: Iterator["PandasDataFrameLike"],
+ # for non first batch, initialStates will be None
+ initialStates: Iterator["PandasDataFrameLike"] = None
+ ) -> Iterator["PandasDataFrameLike"]:
+ handle = StatefulProcessorHandle(statefulProcessorApiClient)
+
+ if statefulProcessorApiClient.handle_state ==
StatefulProcessorHandleState.CREATED:
Review Comment:
You are correct. I also moved out the code block and run a local test with
partition number as "1" to confirm the implementation is correct.
--
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]