title: Multiplying a column in a Spark dataframe by a constant value
body: <p>I am having an issue creating a new column in my Spark dataframe. I'm attemping to create a new column using withColumn() as follows:</p>
  
  <pre><code>.withColumn('%_diff_from_avg', 
       ((col('aggregate_sales') - col('avg_sales')) / col('avg_sales') * 100))
  </code></pre>
  
  <p>This results in some values calculated correctly, but most of the values in my resultant table are null. I don't understand why.</p>
  
  <p>Interestingly, when I drop the '* 100' from the calculation, all my values are populated correctly - i.e. no nulls. For example:</p>
  
  <pre><code>.withColumn('%_diff_from_avg', 
      ((col('aggregate_sales') - col('avg_sales')) / col('avg_sales')))
  </code></pre>
  
  <p>seems to work. </p>
  
  <p>So it seems that the multiplication by 100 is causing the issue.</p>
  
  <p>Can anyone explain why?</p>