I was trying something like this
val df = Seq((50984908,1000)).toDF("x","y")
val myExpression = "x * y"
df.withColumn("z",expr(myExpression)).show()
I can see it causing Integer overflows and it doesnt get cast to Long instead
+--------+----+----------+
| x| y| z|
+--------+----+----------+
|50984908|1000|-554699552|
+--------+----+----------+
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 -> Long), (Float -> Double/BigDecimal)?