Question about stateful processing

fperry
New Contributor III

I'm experiencing an issue that I don't understand. I am using Python's arbitrary stateful processing with structured streaming to calculate metrics for each item/ID. A timeout is set, after which I clear the state for that item/ID and display each ID with its statistics in a resulting data frame. I also save this data frame to a file (delta). However, when I load and display the data frame from the delta file and compare it to the original computed data frame, that is displayed in the notebook, the metrics differ. Why could this be happening? And which data frame is the correct one? Basically, no new data should be considered for the resulting data frame, since the item/ID is only yielded and shown in the resulting data frame when no new data has arrived for the defined timeout. And the data frame that is written to the file is this resulting data frame...