title: Updating some row values in a Spark DataFrame
body: <p>I have a dataframe which I want to merge into another dataframe, but only to affect specific cells rather than a whole row.</p>
  
  <p>Old dataframe:</p>
  
  <pre><code>## +---+----+----+
  ## |key|val1|val2|
  ## +---+----+----+
  ## |  1|  aa|  ab|
  ## |  2|  bb|  bc|
  ## +---+----+----+
  </code></pre>
  
  <p>New dataframe:</p>
  
  <pre><code>## +---+----+
  ## |key|val1|
  ## +---+----+
  ## |  2| bbb|
  ## +---+----+
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>## +---+----+----+
  ## |key|val1|val2|
  ## +---+----+----+
  ## |  1|  aa|  ab|
  ## |  2| bbb|  bc|
  ## +---+----+----+
  </code></pre>
  
  <p>The key is unique in this case so the row to be affected will always be identifiable. The old dataframe will also always contain the keys from the new dataframe.</p>
  
  <p>As dataframes are immutable I'll have to call <code>withColumn</code> to create a new one, presumably by passing in some sort of UDF, but I'm a bit lost when it comes to what that UDF should contain.</p>