Rounding in the databricks SQL editor

Hubert-Dudek
Databricks MVP

In SQL editor (inside SQL experience), executing expressions 1 – 0.999 gives the result 0.

image.png


My blog: https://databrickster.medium.com/

Hubert-Dudek
Databricks MVP

The incorrect result is because of default rounding to format 0.00. We can implement the below solution to solve the problem. It must be applied to every individual query.

Option 1: Edit Visualisation

After clicking Edit visualization, we can change the default Number format to 0.000

image.pngOption 2: Format number

We can use the format_number function to override the default rounding format.image.pngGeneral solution needed

Setting the default format for numbers in SQL Editor should be possible. Currently, when we go to “SQL Admin Console”, there is only the possibility to change the default date & time format.

@Lindsay Olson​ @Prabakar Ammeappin​ @Werner Stinckens​ @Jose Gonzalez​ , please pass it on as feedback if possible.

image.png


My blog: https://databrickster.medium.com/

View solution in original post

Prabakar
Databricks Employee
Databricks Employee
Sure @Hubert Dudek we'll test this internally and will take it to the team.

Thank you @Prabakar Ammeappin​ 


My blog: https://databrickster.medium.com/

-werners-
Esteemed Contributor III

Nice find