title: How to limit decimal values to 2 digits before applying agg function?
body: <p>I am following <a href="https://stackoverflow.com/questions/37032025/how-to-sum-the-values-of-one-column-of-a-dataframe-in-spark-scala">this</a> solution from one of the stack overflow post, my only requirement here is how can I limit the values that I want to sum to 2 digit after the decimal before applying the <code>df.agg(sum())</code> function?</p>
  
  <p>For examples: I have values like below and the sum function sums it,</p>
  
  <pre><code>2.346
  1.549
  </code></pre>
  
  <p>However I want the values to be rounded to 2 digit after the decimal like </p>
  
  <pre><code>2.35
  1.55
  </code></pre>
  
  <p>before summing it. How can I do it? I was not able to find any sub function like <code>sum().round</code> of function <code>sum</code>.</p>
  
  <p>Note: I am using Spark 1.5.1 version.</p>