sahnib commented on code in PR #45376:
URL: https://github.com/apache/spark/pull/45376#discussion_r1576447215
##########
sql/core/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala:
##########
@@ -676,6 +678,43 @@ class KeyValueGroupedDataset[K, V] private[sql](
)
}
+ private[sql] def transformWithState[U: Encoder](
+ statefulProcessor: StatefulProcessor[K, V, U],
+ timeoutMode: TimeoutMode,
+ eventTimeColumnName: String,
+ outputMode: OutputMode): Dataset[U] = {
+ val existingWatermarkDelay = logicalPlan.flatMap {
+ case EventTimeWatermark(_, delay, _) => Seq(delay)
+ case _ => Seq()
+ }
+
+ if (existingWatermarkDelay.isEmpty) {
+ throw QueryCompilationErrors.cannotAssignEventTimeColumn()
+ }
+
+ val transformWithState = TransformWithState[K, V, U](
+ groupingAttributes,
+ dataAttributes,
+ statefulProcessor,
+ timeoutMode,
+ outputMode,
+ child = logicalPlan
+ )
+
+ val twsDS = Dataset[U](
+ sparkSession,
+ transformWithState
+ )
+
+ val delay = existingWatermarkDelay.head
+
+ Dataset[U](sparkSession, EliminateEventTimeWatermark(
+ UpdateEventTimeWatermarkColumn(
Review Comment:
This will add a new node `UpdateEventTimeColumn` after the
`TransformWithState` node. The `UpdateEventTimeColumn` will update the column
metadata and tag the new column as eventTime.
Same thing will happen if we have 2 or more `TransformWithState` operators
chained together. After each TWS operator, we will add the
`UpdateEventTimeColumn` node to tag the correct event time column.
--
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]