Spark - Sum of row values
<p>I have the following DataFrame:</p>

<pre><code>January | February | March
-----------------------------
  10    |    10    |  10
  20    |    20    |  20
  50    |    50    |  50
</code></pre>

<p>I'm trying to add a column to this which is the sum of the values of each row.</p>

<pre><code>January | February | March  | TOTAL
----------------------------------
  10    |    10    |   10   |  30
  20    |    20    |   20   |  60
  50    |    50    |   50   |  150
</code></pre>

<p>As far as I can see, all the built in aggregate functions seem to be for calculating values in single columns. How do I go about using values across columns on a per row basis (using Scala)?</p>

<p>I've gotten as far as</p>

<pre><code>val newDf: DataFrame = df.select(colsToSum.map(col):_*).foreach ...
</code></pre>