You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 刘建刚 <li...@gmail.com> on 2019/09/04 06:49:50 UTC

How to calculate one day's uv every minute by SQL

      We want to calculate one day's uv and show the result every minute .
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<Bitmap> to store all the
distinct userIds from 00:00:00 to last minute. For current minute, we union
the minute's data with ValueState<Bitmap> to obtain a new
ValueState<Bitmap> 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.