jingz-db commented on code in PR #48838: URL: https://github.com/apache/spark/pull/48838#discussion_r1861301227
########## python/pyspark/sql/tests/pandas/test_pandas_transform_with_state.py: ########## @@ -858,33 +913,30 @@ def init(self, handle: StatefulProcessorHandle) -> None: self.handle = handle self.max_state = handle.getValueState("max_state", state_schema) - def handleInputRows( - self, key, rows, timer_values, expired_timer_info - ) -> Iterator[pd.DataFrame]: - if expired_timer_info.is_valid(): - self.max_state.clear() - self.handle.deleteTimer(expired_timer_info.get_expiry_time_in_ms()) - str_key = f"{str(key[0])}-expired" - yield pd.DataFrame( - {"id": (str_key,), "timestamp": str(expired_timer_info.get_expiry_time_in_ms())} - ) + def handleExpiredTimer(self, key, timer_values, expired_timer_info) -> Iterator[pd.DataFrame]: + self.max_state.clear() + self.handle.deleteTimer(expired_timer_info.get_expiry_time_in_ms()) + str_key = f"{str(key[0])}-expired" + yield pd.DataFrame( + {"id": (str_key,), "timestamp": str(expired_timer_info.get_expiry_time_in_ms())} + ) - else: - timestamp_list = [] - for pdf in rows: - # int64 will represent timestamp in nanosecond, restore to second - timestamp_list.extend((pdf["eventTime"].astype("int64") // 10**9).tolist()) + def handleInputRows(self, key, rows, timer_values) -> Iterator[pd.DataFrame]: + timestamp_list = [] + for pdf in rows: + # int64 will represent timestamp in nanosecond, restore to second + timestamp_list.extend((pdf["eventTime"].astype("int64") // 10**9).tolist()) - if self.max_state.exists(): - cur_max = int(self.max_state.get()[0]) - else: - cur_max = 0 - max_event_time = str(max(cur_max, max(timestamp_list))) + if self.max_state.exists(): + cur_max = int(self.max_state.get()[0]) + else: + cur_max = 0 + max_event_time = str(max(cur_max, max(timestamp_list))) - self.max_state.update((max_event_time,)) - self.handle.registerTimer(timer_values.get_current_watermark_in_ms()) + self.max_state.update((max_event_time,)) + self.handle.registerTimer(timer_values.get_current_watermark_in_ms() + 1) Review Comment: I modified this to current batch timestamp + 1 for testing with more common use cases as registering with current batch timestamp is not a very common use case. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org