title: Spark Not able to Infer Types to Higher Precision During Type Overflows
body: <p>I was trying something like this</p>
  <pre><code>val df = Seq((50984908,1000)).toDF(&quot;x&quot;,&quot;y&quot;)
  val myExpression = &quot;x * y&quot;
  df.withColumn(&quot;z&quot;,expr(myExpression)).show()
  </code></pre>
  <p>I can see it causing Integer overflows and it doesnt get cast to Long instead</p>
  <pre><code>+--------+----+----------+
  |       x|   y|         z|
  +--------+----+----------+
  |50984908|1000|-554699552|
  +--------+----+----------+
  </code></pre>
  <p>Can somebody please provide suggestions how these overflows can be avoided?
  Is there a way where Spark can automatically infer higher precision for types correctly (eg : Integer -&gt; Long), (Float -&gt; Double/BigDecimal)?</p>