SQL Cast of Double to String

Dear community,

does anyone know how we can unify the cast of double values to string values between PostgreSQL and SparkSQL?
The problem is with double values that don’t have fractional digits. For example 1 will be cast to a string “1.0” in SparkSQL but will be cast to “1” in PostgreSQL.

1 Like

If you don’t need the same query for both systems you can use their respectable formatting functions
format_number functions (Spark 3.3.1 JavaDoc)
and to_char
PostgreSQL: Documentation: 15: 9.8. Data Type Formatting Functions

I was thinking about those but there I have to decide for the number of decimal places and for PostgreSQL even for the amount of numbers “left of the comma”, don’t I?