bogao007 commented on code in PR #41558:
URL: https://github.com/apache/spark/pull/41558#discussion_r1231419935
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala:
##########
@@ -462,6 +462,15 @@ abstract class KeyValueGroupedDataset[K, V] private[sql]
() extends Serializable
UdfUtils.coGroupFunctionToScalaFunc(f))(encoder)
}
+ protected def flatMapGroupsWithStateHelper[S: Encoder, U: Encoder](
+ outputMode: OutputMode,
+ timeoutConf: GroupStateTimeout,
+ initialState: KeyValueGroupedDataset[K, S],
Review Comment:
This is the comment for the change here
https://github.com/apache/spark/pull/41558#discussion_r1227341997, we actually
already have something similar that's introduced by @zhenlineo
[here](https://github.com/apache/spark/blob/49dc2dbcbb1d763d8ee0f2034e82347eebe50d0f/sql/core/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala#L672-L681).
I would actually prefer the current approach with a helper function since it
reduces the code duplication a lot. There are several differences between the
original implementation and Spark Connect, a major one is that we separate the
implementation out of the public methods, in that case I think a single helper
method should be enough.
Another thing is that with the original API design, it doesn't contain much
logics in the actual implementation, it just constructs a new `Dataset` object
which doesn't make much sense to abstract out any common logics. But for the
Spark Connect implementation, it contains some logics there to determine which
value we should pass and might result in duplicated code if we have 2 different
methods for `flatMapGroupsWithState` and `mapGroupsWIthState`. @WweiL let me
know what you think
--
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]