bogao007 commented on code in PR #48290:
URL: https://github.com/apache/spark/pull/48290#discussion_r1808091633


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/python/TransformWithStateInPandasStateServer.scala:
##########
@@ -389,6 +520,63 @@ class TransformWithStateInPandasStateServer(
         } else {
           sendResponse(1, s"List state $stateName already exists")
         }
+        case StateVariableType.MapState => if (!mapStates.contains(stateName)) 
{
+          val valueSchema = StructType.fromString(mapStateValueSchemaString)
+          val valueExpressionEncoder = 
ExpressionEncoder(valueSchema).resolveAndBind()
+          val state = if (ttlDurationMs.isEmpty) {
+            statefulProcessorHandle.getMapState[Row, Row](stateName,
+              Encoders.row(schema), Encoders.row(valueSchema))
+          } else {
+            statefulProcessorHandle.getMapState[Row, Row](stateName, 
Encoders.row(schema),
+              Encoders.row(valueSchema), 
TTLConfig(Duration.ofMillis(ttlDurationMs.get)))
+          }
+          mapStates.put(stateName,
+            MapStateInfo(state, schema, valueSchema, 
expressionEncoder.createDeserializer(),
+              expressionEncoder.createSerializer(), 
valueExpressionEncoder.createDeserializer(),
+              valueExpressionEncoder.createSerializer()))
+          sendResponse(0)
+        } else {
+          sendResponse(1, s"Map state $stateName already exists")
+        }
+    }
+  }
+
+  private def sendIteratorAsArrowBatches[T](

Review Comment:
   yeah, if the timer PR is merged first, I can rebase and apply the update. 
Otherwise let's just keep the current implementation, we can do the rebase in 
the timer PR.



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