title: How to Find the maximum consecutive years for each ID using Scala / Spark
body: <p>I have certain ID's for each row with the respective years of operation:</p>
  
  <p>Example:</p>
  
  <pre><code>ID   YEAR
  
  A1   1999
  A2   2000
  A1   2000
  B1   1998
  A1   2002
  </code></pre>
  
  <p>Now, I need to Identify the No. of consecutive years for each ID 
  Result,</p>
  
  <pre><code>A1 : 2  because[1999, 2000 ] 
  </code></pre>
  
  <p>etc .,</p>