Revenue Totals Wrong After an Upstream Type Change

SQL · schema drift · Beginner · about 15 minutes

Impact

After an upstream release changed transactions.amount from a number to text, the finance revenue query started returning wrong totals without failing.

Symptoms

Evidence

Schema change on transactions.amount

type
before the releaseDECIMAL(12,2)
after the releaseVARCHAR(50)

transactions, selected rows

tx_idcustomeramount
1Alice'100'
2Bob'abc'
4DanNULL
5Eve' 500 '
6Frank'N/A'

Row profile

measurerows
rows in transactions8
amount looks like a number4
amount is text or NULL4

Query warnings

Warning 1292  Truncated incorrect DECIMAL value: 'abc'
Warning 1292  Truncated incorrect DECIMAL value: 'N/A'
Warning 1292  Truncated incorrect DECIMAL value: 'unknown'

Investigation task

Return only the transactions whose amount is a valid number, with amount converted to DECIMAL(12,2): tx_id, customer, amount, ordered by tx_id.

The fix is written and graded in the regular challenge editor. The postmortem unlocks once the incident is resolved.

All production incidents