anishshri-db commented on code in PR #43961:
URL: https://github.com/apache/spark/pull/43961#discussion_r1430640516
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/object.scala:
##########
@@ -569,6 +569,41 @@ case class FlatMapGroupsWithState(
copy(child = newLeft, initialState = newRight)
}
+object TransformWithState {
+ def apply[K: Encoder, V: Encoder, U: Encoder](
+ groupingAttributes: Seq[Attribute],
Review Comment:
Done
##########
sql/core/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala:
##########
@@ -642,6 +642,37 @@ class KeyValueGroupedDataset[K, V] private[sql](
outputMode, timeoutConf, initialState)(f)(stateEncoder, outputEncoder)
}
+ /**
+ * (Scala-specific)
+ * Invokes methods defined in the stateful processor used in arbitrary state
API v2.
+ * We allow the user to act on per-group set of input rows along with keyed
state and the
+ * user can choose to output/return 0 or more rows.
+ * For a static/batch dataset, this operator is not supported and will throw
an exception.
+ * For a streaming dataframe, we will repeatedly invoke the interface
methods for new rows
+ * in each trigger and the user's state/state variables will be stored
persistently across
+ * invocations.
+ *
+ * @tparam U The type of the output objects. Must be encodable to Spark SQL
types.
+ * @param statefulProcessor Instance of statefulProcessor whose functions
will be invoked by the
+ * operator.
+ * @param outputMode The output mode of the stateful processor. Defaults to
APPEND mode.
+ *
+ */
+ def transformWithState[U: Encoder]
+ (statefulProcessor: StatefulProcessor[K, V, U],
Review Comment:
Done
--
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]