title: Collapsing column values in spark dataframes
body: <p>I have 2 DataFrames</p>
  
  <pre><code>case class UserTransactions(id: Long, transactionDate: java.sql.Date, currencyUsed: String, value: Long)
  
  ID, TransactionDate, CurrencyUsed, value
  1, 2016-01-05, USD, 100
  1, 2016-01-09, GBP, 150 
  1, 2016-02-01, USD, 50
  1, 2016-02-10, JPN, 10
  2, 2016-01-10, EURO, 50
  2, 2016-01-10, GBP, 100
  
  case class ReportingTime(userId: Long, reportDate: java.sql.Date)
  
  userId, reportDate
  1, 2016-01-05
  1, 2016-01-31
  1, 2016-02-15
  2, 2016-01-10
  2, 2016-02-01
  </code></pre>
  
  <p>Now I want to get summary by combining all previously used currencies by <code>userId</code>, <code>reportDate</code> and <code>sum</code>. The results should look like:</p>
  
  <pre><code>userId, reportDate, trasactionSummary
  1, 2016-01-05, None
  1, 2016-01-31, (USD -&gt; 100)(GBP-&gt; 150) // combined above 2 transactions less than 2016-01-31
  1, 2016-02-15, (USD -&gt; 150)(GBP-&gt; 150)(JPN-&gt;10) // combined transactions less than 2016-02-15
  2, 2016-01-10, None
  2, 2016-02-01, (EURO-&gt; 50) (GBP-&gt; 100)
  </code></pre>
  
  <p>What is the best way to do this to do this? We have over 300 million transactions where each user can have up to 10,000 transactions.</p>