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


##########
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"]:

Review Comment:
   Add the above in the comment.



##########
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:
   Would be None. This is a bit hacky. We pass in the python eval type purely 
based on whether the input `initialState` dataframe is None or not. For 
non-empty input initial state and non first batch, we will still eval UDF as 
`transformWithStateWithInitStateUDF` 
[here](https://github.com/apache/spark/pull/48005/files#diff-5862151bb5e9fe7a6b2d1978301c235504dcc6c1bbbd1f9745a204a3ba93146eR576).
 As JVM will start a eval type of `transformWithStateUDF` PythonRunner for non 
first batch, we will get `initialStates` as None as it is the positional value: 
`initialStates: Iterator["PandasDataFrameLike"] = None`



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