title: Spark dataframe decimal precision
body: <p>I have one dataframe:</p>
  
  <pre><code>val groupby = df.groupBy($"column1",$"Date")    
  .agg(sum("amount").as("amount"))
  .orderBy($"column1",desc("cob_date"))
  </code></pre>
  
  <p>When applyin the window function for adding new column difference:</p>
  
  <pre><code>val windowspec= Window.partitionBy("column1").orderBy(desc("DATE"))
  
  groupby.withColumn("diffrence" ,lead($"amount", 1,0).over(windowspec)).show()
  
  
  +--------+------------+-----------+--------------------------+
  | Column | Date       | Amount    | Difference               |
  +--------+------------+-----------+--------------------------+
  | A      | 3/31/2017  | 12345.45  | 3456.540000000000000000  |
  +--------+------------+-----------+--------------------------+
  | A      | 2/28/2017  | 3456.54   | 34289.430000000000000000 |
  +--------+------------+-----------+--------------------------+
  | A      | 1/31/2017  | 34289.43  | 45673.987000000000000000 |
  +--------+------------+-----------+--------------------------+
  | A      | 12/31/2016 | 45673.987 | 0.00E+00                 |
  +--------+------------+-----------+--------------------------+
  </code></pre>
  
  <p>I'm getting decimal as with trailing zeros .When I did <code>printSchema()</code> for the above dataframe getting the datatype for difference: <code>decimal(38,18)</code>.Can some one tell me how to change the datatype to <code>decimal(38,2)</code> or remove the trailing zeros</p>