Remove ".000000" from a field like this: "2386.000000"

Viewed 50

How do I remove the ".000000" part of the "2386.000000" field? I want to leave only the numerical part before the dot in databricks

2 Answers

You can use cast

select cast(2386.000000 as int) i

There are many ways to convert a float to an int. The cast() function is just one.

Please see the following link for all supported Spark SQL functions.

https://spark.apache.org/docs/2.3.0/api/sql/index.html#round

In my solution, I use the round() function. As long as you get the correct answer, the path you take may differ.

enter image description here

Related