title: PySpark UDF returns a string but I need an integer
body: <p>I have this code, where I return from UDF an Integer type, but system change this to string.</p>
  <p>How can I correct this?</p>
  <pre><code># Define a UDF to determine the number of pixels per image
  def dogPixelCount(doglist):
  totalpixels = 0
  for dog in doglist:
      totalpixels += (dog[3] - dog[1]) * (dog[4] - dog[2])
  return totalpixels
  
  # Define a UDF for the pixel count
  udfDogPixelCount = F.udf(dogPixelCount, IntegerType())
  joined_df = joined_df.withColumn('dog_pixels', udfDogPixelCount('dogs'))
  
  # Create a column representing the percentage of pixels
  joined_df = joined_df.withColumn('dog_percent', ('dog_pixels' / sum('dog_pixels') ) * 100 )
  
  # Show the first 10 annotations with more than 60% dog
  joined_df.filter(dog_percent &gt; 60).show(10)
  </code></pre>