tdas commented on a change in pull request #33093:
URL: https://github.com/apache/spark/pull/33093#discussion_r661556881



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/FlatMapGroupsWithStateExec.scala
##########
@@ -101,51 +172,48 @@ case class FlatMapGroupsWithStateExec(
       case ProcessingTimeTimeout =>
         require(batchTimestampMs.nonEmpty)
       case EventTimeTimeout =>
-        require(eventTimeWatermark.nonEmpty)  // watermark value has been 
populated
+        require(eventTimeWatermark.nonEmpty) // watermark value has been 
populated
         require(watermarkExpression.nonEmpty) // input schema has watermark 
attribute
       case _ =>
     }
 
-    child.execute().mapPartitionsWithStateStore[InternalRow](
-      getStateInfo,
-      groupingAttributes.toStructType,
-      stateManager.stateSchema,
-      indexOrdinal = None,
-      session.sessionState,
-      Some(session.streams.stateStoreCoordinator)) { case (store, iter) =>
-        val allUpdatesTimeMs = longMetric("allUpdatesTimeMs")
-        val commitTimeMs = longMetric("commitTimeMs")
-        val updatesStartTimeNs = System.nanoTime
+    if (hasInitialState) {
+      // If the user provided initial state we need to have the initial state 
and the
+      // data in the same partition so that we can still have just one commit 
at the end.
 
+      val storeConf = new StateStoreConf(session.sqlContext.sessionState.conf)
+      val hadoopConfBroadcast = sparkContext.broadcast(
+        new 
SerializableConfiguration(session.sqlContext.sessionState.newHadoopConf()))
+      child.execute().stateStoreAwareZipPartitions(
+        initialState.execute(),
+        getStateInfo,
+        storeNames = Seq(),
+        session.sqlContext.streams.stateStoreCoordinator) {
+        case (partitionId, childDataIterator, initStateIterator) =>
+          val stateStoreId = StateStoreId(

Review comment:
       nit: give a few empty lines here to explain this monolith code.




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