I have a stream delta of numbers in a kafka topic that needs to be aggregated in a special way, i.e.:
aggregate[0] = 0
aggregate[N] = aggregate[N-1] * (N - 1) / N + delta[N - 1] / N
(exact formula is irrelevant, note the dependency on the previous element in aggregate though)
Essentially, I need to subscribe to two kafka topics simultaneously, where I advance in both topics at the same time: when I read an item in the delta topic, I need to read the the corresponding item from the aggregate topic as well, and write the result into the the aggregate topic, before the next item in the delta topic is consumed.
Is this at all possible in kafka? Could ksql with a clever join help?