I am new to Spark. Any help will be appreciated. Is there any alternative for sql's FORMAT() in Spark SQL. My core logic is written as SQL and running with spark.sql("query"). I have a requirement to convert the id to 4 digit.
For example, if if is 1, it should be converted to 0001, if it is 12, then 0012. I know in SQL, we can do it as FORMAT("%04d", id) as id. But this is giving me error in Spark SQL saying FORMAT is not a function registered. Found format_number and format_string in Spark's documentation, but not helping in my case.
Note: I don't want to do this in my java code, but would like to do in SQL query itself.