title: Distinct user in cassandra , how to do that?
body: <p>I working on an big data application in scala.</p>
  
  <p>I use kafka, spark (with kafka streaming) and Cassandra as storage.</p>
  
  <p>I have an application outside of spark which request Cassandra to show statistics result like number of download.</p>
  
  <p>I have a problemat with the user statistics.</p>
  
  <p>I need to count the number of unique users in a period (could be 1 day ,6 days  7 days, one month or whatever) by publisher_id , or by publisher_id + app_id or even for all publisher_id. </p>
  
  <p>I need to count in live because I don t know what is the period chosen by the user. </p>
  
  <p>My raw data for session user is : </p>
  
  <pre><code>CREATE TABLE tests2.raw_sessions (
  date_event timeuuid,
      year int,
      month int,
      day int,
      hour int,
      publisher_id uuid,
      app_id text,
      user_id text,
       session_id text,
       PRIMARY KEY (date_event, year, month, day, hour, publisher_id, app_id, 
       user_id, session_id)
  ) WITH CLUSTERING ORDER BY (year DESC, month DESC, day DESC, hour DESC, publisher_id ASC, app_id ASC, user_id ASC, session_id ASC)
  </code></pre>
  
  <p>I created multiple tables and tried a lot of things in cassandra. I tried to use the distinct keyword in cassandra but it s only with static column (but it s not static column ) and it can be a unique partition key in a table (i need to filter on the date , and the publisher id , app_id</p>
  
  <p>I thought about using a Postgres database but with kafka streaming this is not really optimal isn't it?</p>
  
  <p>What is THE solution I should use for that?</p>