title: Spark Scala Cumulative Unique Count by Date
body: <p>I have a dataframe that gives a set of id numbers and the date at which they visited a certain location and I’m trying to find a way in spark scala to get the number of unique people (“id”) that have visited this location on or before each day so that one id number won’t be counted twice if they visit on 2019-01-01 and then again on 2019-01-07 for example.</p>
  
  <pre><code>df.show(5,false)
  
  +---------------+
  |id  |date      |
  +---------------+
  |3424|2019-01-02|
  |8683|2019-01-01|
  |7690|2019-01-02|
  |3424|2019-01-07|
  |9002|2019-01-02|
  +---------------+
  </code></pre>
  
  <p>I want the output to look like this: where I groupBy(“date”) and get the count of unique id’s as a cumulative number.  (So for example: next to 2019-01-03, it would give the distinct count of id’s on any day up to 2019-01-03)</p>
  
  <pre><code>+----------+-------+
  |date      |cum_ct |
  +----------+-------+
  |2019-01-01|xxxxx  |
  |2019-01-02|xxxxx  |
  |2019-01-03|xxxxx  |
  |...       |...    |
  |2019-01-08|xxxxx  |
  |2019-01-09|xxxxx  |
  +------------------+
  </code></pre>
  
  <p>What would be the best way to do this after df.groupBy("date")</p>