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



##########
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(),

Review comment:
       i dont think this is quite right yet. Making this Seq empty probably 
means that it does not consider the locality of any state store. Maybe this 
should be set as the `StateStoreId.DEFAULT_STORE_NAME`
   
   we will need tests for this. using git history to see how tests were added 
for `stateStoreAwareZipPartitions`




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