Hi @Aviral-Bhardwaj,
I don't think this is a display issue, and it isn't normal rounding either.
- In your first pair, 24.5638 became 24.560000 and 18.4421 became 18.440000. That's truncation (floor) to 2 decimal places.
- In your second pair, 24.5638 became 24.5700 and 18.4421 became 18.4500. That's a ceiling to 2 decimal places.
In both cases, the trailing zeros indicate that the extra digits had already been removed before the data reached the table. They were later padded back out to a wider scale.
Databricks doesn't silently floor or ceil DECIMAL values. A CAST to a smaller scale rounds half up, so 24.5638 cast to DECIMAL(10,2) gives 24.56, not 24.57. The
DECIMAL type docs have examples. DECIMAL columns are also displayed at their full declared scale. So something in your ingestion path is probably converting to 2 decimals on purpose, most likely an explicit FLOOR, CEIL or TRUNC, a target schema with scale 2, or a step in the extract tool.
CAn you run DESCRIBE TABLE on the Databricks table and on any staging or intermediate tables to check each column's precision and scale? You can also go through the pipeline code and any ETL or extract tool settings for rounding functions or a DECIMAL(p,2) cast. If you land files first, check what the CSV or Parquet files actually contain, and make sure you read them with an explicit DECIMAL schema rather than inferSchema.
If you read over JDBC, check the type mapping. For Oracle, for example, NUMBER without a declared precision maps to DECIMAL(38,10) (
Oracle type mappings). That keeps your 4 decimals, but a custom schema or a downstream cast can still cut them. You can set the exact type yourself with the JDBC customSchema option, for example customSchema "amount DECIMAL(18,4)".
Avoid DOUBLE and FLOAT for financial data. They are base-2 types and can't represent many base-10 decimals exactly (
DOUBLE type).
Pick one record, such as the 24.5638 row, and trace it through each stage: source query result, landed file, bronze table, then final table. Run typeof(col) on the value at every stage. The stage where it first shows up as 24.56 or 24.57 is where the conversion happens. Define the column as DECIMAL with the same precision and scale as the source from that stage onward, and the values should match exactly.
If you share how you ingest the data (JDBC, Auto Loader, Lakeflow Connect or a third-party tool) and the column definition in the source, the community can help narrow it down.
If this answer resolves your question, could you mark it as โAccept as Solutionโ? That helps other users quickly find the correct fix.
Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***