We want to calculate one day's uv and show the result every minute by Flink.
We have implemented this by java code:
dataStream.keyBy(dimension)
.incrementWindow(Time.days(1), Time.minutes(1))
.uv(userId)
The input data is big. So we use ValueState to store all the distinct userIds from 00:00:00 to last minute. For current minute, we union the minute's data with ValueState to obtain a new ValueState and output the current uv.
The problem is how to translate the java code to sql? We expect the sql to be like this:
select incrementWindow_end, dimension, distinct(userId) from table group by incrementWindow(Time.days(1), Time.minutes(1)), dimension
Anyone can give me some suggestions? Thank you very much.