I have a amount value, which we are reading from a file and trying to print on the console.
When we try to print, it is showing as Exponential and another issue is when we try to cast it is coming as null.
Input value:
{"amt":987654321111.0}
Sample Code:
df.show();
df.registerTempTable("input");
DataFrame outputDF = sqlContext.sql("select cast(amt as decimal) from input");
outputDF.show();
Output:
+----------------+
| amt|
+----------------+
|9.87654321111E11|
+----------------+
root
|-- amt: double (nullable = true)
root
|-- amt: decimal(10,0) (nullable = true)
+----+
| amt|
+----+
|null|
+----+