Databricks 0E-18


                Databricks 0E-18

Databricks, like other Spark-based systems, may display decimal values with many trailing zeros in scientific notation (e.g., 0E-18). This is due to how Spark handles decimal types with a large scale (number of digits after the decimal point).

Why this happens:

  • Storage Efficiency: Scientific notation is a compact way to represent very small or large numbers, saving storage space.
  • Display: For numbers with many decimal places, scientific notation can be easier to read than a long string of zeros.

How to address this:

If you need to display or work with the decimal values in their full form (without scientific notation), there are a few options:

  1. Casting: You can cast the decimal column to a string type in Databricks:
SELECT CAST(your_decimal_column AS STRING) FROM your_table
  1. Formatting: Use a formatting function in Databricks to control how decimals are displayed:
SELECT FORMAT_NUMBER(your_decimal_column, 18) FROM your_table 

This will display the value with up to 18 decimal places. Adjust the number as needed.

  1. Custom UDF: If you need more flexibility, you can create a custom User Defined Function (UDF) in Spark to convert scientific notation to plain text. Examples of this can be found on Stack Overflow or Databricks forums.

Example (Casting):

Imagine you have a DataFrame with a column decimal_col containing the value 0E-18.

from pyspark.sql.functions import col

df = df.withColumn("decimal_col_string", col("decimal_col").cast("string"))

This will create a new column decimal_col_string with the value 0.000000000000000000.

Databricks Training Demo Day 1 Video:

You can find more information about Databricks Training in this Dtabricks Docs Link



Unogeeks is the No.1 IT Training Institute for Databricks Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on Databricks Training here – Databricks Blogs

Please check out our Best In Class Databricks Training Details here – Databricks Training

 Follow & Connect with us:


For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at:

Our Website ➜

Follow us:





Leave a Reply

Your email address will not be published. Required fields are marked *