title: How to add days (as values of a column) to date?
body: <p>I have a problem with adding days (numbers) to date format columns in Spark. I know that there is a function <code>date_add</code> that takes two arguments - date column and integer:</p>
  
  <pre><code>date_add(date startdate, tinyint/smallint/int days)
  </code></pre>
  
  <p>I'd like to use a column value that is of type integer instead (not an integer itself).</p>
  
  <p>Say I have the following dataframe:</p>
  
  <pre><code>val data = Seq(
      (0, "2016-01-1"),
      (1, "2016-02-2"),
      (2, "2016-03-22"),
      (3, "2016-04-25"),
      (4, "2016-05-21"),
      (5, "2016-06-1"),
      (6, "2016-03-21"))
  ).toDF("id", "date")
  </code></pre>
  
  <p>I can simply add integers to dates:</p>
  
  <pre><code>val date_add_fun = 
  data.select(
      $"id",
      $"date",
      date_add($"date", 1)
  )
  </code></pre>
  
  <p>But I cannot use a column expression that contains the values:</p>
  
  <pre><code>val date_add_fun = 
  data.select(
      $"id",
      $"date",
      date_add($"date", $"id")
  )
  </code></pre>
  
  <p>It gives error:</p>
  
  <pre><code>&lt;console&gt;:60: error: type mismatch;
   found   : org.apache.spark.sql.ColumnName
   required: Int
             date_add($"date", $"id")
  </code></pre>
  
  <p>Does anyone know if it is possible to use column is date_add function? Or what is the workaround?</p>