It seems that PyFlink udtaf produces different results in the same sliding window. It can be reproduced with the given code and input. It is not always happening but the possibility is relatively high.
The incorrect output is the following:
We can see that the output contains different `val_sum` at `window_time` 2022-01-01 00:01:59.999.