jingz-db commented on code in PR #47878:
URL: https://github.com/apache/spark/pull/47878#discussion_r1815572484
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/python/TransformWithStateInPandasStateServer.scala:
##########
@@ -137,11 +148,57 @@ class TransformWithStateInPandasStateServer(
handleStatefulProcessorCall(message.getStatefulProcessorCall)
case StateRequest.MethodCase.STATEVARIABLEREQUEST =>
handleStateVariableRequest(message.getStateVariableRequest)
+ case StateRequest.MethodCase.TIMERREQUEST =>
+ handleTimerRequest(message.getTimerRequest)
case _ =>
throw new IllegalArgumentException("Invalid method call")
}
}
+ private[sql] def handleTimerRequest(message: TimerRequest): Unit = {
+ message.getMethodCase match {
+ case TimerRequest.MethodCase.TIMERVALUEREQUEST =>
+ val timerRequest = message.getTimerValueRequest()
+ timerRequest.getMethodCase match {
+ case TimerValueRequest.MethodCase.GETPROCESSINGTIMER =>
+ val procTimestamp: Long =
+ if (batchTimestampMs.isDefined) batchTimestampMs.get else -1L
+ sendResponseWithLongVal(0, null, procTimestamp)
+ case TimerValueRequest.MethodCase.GETWATERMARK =>
+ val eventTimestamp: Long =
+ if (eventTimeWatermarkForEviction.isDefined)
eventTimeWatermarkForEviction.get
+ else -1L
+ sendResponseWithLongVal(0, null, eventTimestamp)
+ case _ =>
+ throw new IllegalArgumentException("Invalid timer value method
call")
+ }
+
+ case TimerRequest.MethodCase.EXPIRYTIMERREQUEST =>
+ val expiryRequest = message.getExpiryTimerRequest()
+ val expiryTimestamp = expiryRequest.getExpiryTimestampMs
+ if (!expiryTimestampIter.isDefined) {
+ expiryTimestampIter =
+ Option(statefulProcessorHandle.getExpiredTimers(expiryTimestamp))
+ }
+ // expiryTimestampIter could be None in the TWSPandasServerSuite
+ if (!expiryTimestampIter.isDefined ||
!expiryTimestampIter.get.hasNext) {
+ // iterator is exhausted, signal the end of iterator on python client
+ sendResponse(1)
Review Comment:
Answered below in the "interleaved" comments.
--
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]