Skip to content
ITACC
Abstract sphere of dots and lines

Data Migration

Oracle NUMBER to Databricks DECIMAL: keeping exact numbers exact after migration

By Ed, CTO @ ITACC · · 4 min read

Key takeaways

  • Oracle NUMBER and Databricks DECIMAL are both exact, but they don't decide precision the same way.
  • Migrated code runs without errors and some amounts still come out a cent off, rounded or empty.
  • The damage lands where it hurts most: invoices, balances, tax and reconciliations.
  • Sample checks and totals can look perfect while individual values differ.
  • Across a real Oracle estate, proving every number still matches is specialist work.

Short answer: Oracle NUMBER stores exact decimal values with up to 38 significant digits, and a column or variable declared as plain NUMBER accepts almost any value you give it. Databricks DECIMAL is exact too, and also tops out at 38 digits, but every DECIMAL has a fixed precision and scale, and a bare DECIMAL means DECIMAL(10,0): ten digits, no decimals. Where the two don't line up, migrated code still runs, and numbers can come out rounded, cut short, empty, or failing on the day a big value arrives.

This is the second article in our series on Oracle to Databricks migration. The first covered Oracle empty strings and NULL. For the bigger picture, start with our guide to migrating Oracle stored procedures to Databricks.

Two platforms, two ideas of an exact number

Oracle's NUMBER data type holds fixed and floating-point decimal numbers with up to 38 significant digits. If you declare NUMBER without a precision or scale, Oracle stores values as given, at its maximum precision. Many Oracle schemas and PL/SQL programs were written that way, and nobody had to think about how many decimals a calculation needed.

Databricks works differently. Its DECIMAL type has a declared precision (up to 38) and scale, with DECIMAL(10,0) as the default when none is given. Calculation results get a precision and scale too, worked out from the inputs, and when a result would need more than 38 digits, something has to give. The ANSI mode setting then decides whether a value that doesn't fit stops the job with an error or quietly becomes NULL.

The usual shortcut, mapping NUMBER to DOUBLE, swaps exact decimals for binary floating point. That's fine for some measurements. For money, quantities and identifiers, it trades one problem for another.

Where it shows up

In our side-by-side runs on Oracle and Databricks, numeric differences typically surface as:

  • Amounts that lose their cents. A value lands in a column or variable with no decimals, and 19.99 becomes 20.
  • Totals that are a cent off. An invoice, tax line or allocation rounds differently, but only for some combinations of values.
  • Jobs that fail months later. Everything passes testing, then a large account number or ID arrives and the job stops with an out-of-range error.
  • Values that quietly go empty. Depending on settings, a number that doesn't fit becomes NULL instead of raising an error.
  • Reconciliations that never quite close. Floating-point values drift in the last digits, and finance spends days explaining differences nobody introduced on purpose.

Most of these raise no error. The job turns green and the dashboard looks normal.

A real example

One thing our validation runs caught was a small function that multiplied an amount by a rate and rounded the result to cents. On Oracle it returned 1.23. The converted version on Databricks returned 1.24. The code was correct line for line. The difference came from how many decimal places the intermediate result kept before the final rounding, so it appeared only for certain values, and most test rows matched perfectly.

Another run showed the opposite failure: a converted function that worked for every test value until it met a 19-digit number, then stopped with an out-of-range error. On Oracle, the same number had never been a problem.

Neither showed up in a code review. Both showed up only when the new results were compared with the legacy results, value by value.

Why it's hard to catch at scale

One cent on one row looks trivial. Across hundreds of procedures and years of financial data, it isn't:

  • It spreads. A rounded intermediate value feeds a balance, which feeds an allocation, which feeds a report three steps later.
  • It hides. It appears only for certain combinations of values, so samples, row counts and even most totals can match.
  • It's not alone. Numeric precision interacts with NULL handling, date logic and settings that can differ between Databricks compute types.
  • It needs decisions. How many digits each column really needs, and whether a one-cent difference is acceptable for a given report, are business calls that finance has to own.

That's why migrations rarely stall on rewriting SQL. They stall on proving the numbers.

How ITACC handles it

ITACC is now a Databricks Brickbuilder Bronze Partner, part of Databricks' partner program. Moving Oracle workloads onto Databricks safely is the work we focus on.

We've built our own migration tooling and method around one principle: every migrated object is proven against your legacy results, or flagged with the reason. Nothing silently wrong.

We convert Oracle SQL and PL/SQL to Databricks while keeping the behaviour your business logic depends on, including exact numbers, and we hand you the evidence: what matches, what differs, and why, down to the last decimal. Your team spends its time on decisions, not on chasing cents.

The next article in this series covers cursors and row-by-row loops on Databricks. If you also run Informatica, see what maps cleanly from PowerCenter to Databricks.

ITACC is an AI and data engineering partner based in Oakville, Ontario, and a Databricks Brickbuilder Bronze Partner. Learn more about our data and workflow automation work.

Frequently asked questions

Is Databricks DECIMAL the same as Oracle NUMBER?

Not quite. Both store exact decimal values with up to 38 digits, but every Databricks DECIMAL has a fixed precision and scale, and a bare DECIMAL means DECIMAL(10,0). Oracle's plain NUMBER has no fixed scale, so there is no exact one-to-one match.

Can we use DOUBLE for Oracle NUMBER columns?

DOUBLE is binary floating point, so many decimal values are stored as close approximations. That can be acceptable for some measurements, but it's risky for money, quantities and identifiers. It's a decision per column, and it needs proof against the legacy results.

Will we see an error if our numbers change after migration?

Sometimes. A value too large for its type can stop a job with an error. But lost decimals and rounding differences usually raise no error at all, which is why comparing results matters more than checking that the code runs.

How do we know if our Oracle estate is affected?

Almost every Oracle estate uses NUMBER heavily, so the question is where it matters. The reliable way to know is to compare migrated outputs with legacy outputs on real data. We can show you on one of your own procedures.

Abstract flowing lines of light

Ready to take AI past the demo?

Tell us what you want to build. We'll reply within one business day, and we're happy to sign an NDA first.