All tests are green. Why is the report still wrong?
A quality gate should protect meaning, completeness, and reconciliation, not just check whether columns are filled.
Not null does not mean correct.
Three transactions have IDs, dates, and amounts. Everything is filled in, but the batch was delivered twice, so the total increased. The not-null test was not wrong. Its question was too narrow. Tests should follow risks: duplicate keys, orphaned relationships, delays, changed values, and drifting aggregates. A thousand tests without a risk map only create more green indicators.
The dbt documentation provides patterns for unique, not_null, accepted_values, relationships, and custom SQL tests. A tool helps express expectations. Choosing the important expectations remains the work of a team that understands its sources and consumers. A passing status is not a universal certificate of correctness.
Build several layers of evidence.
Structural checks validate schema and identity. Relationship checks validate references. Temporal checks validate freshness. Business rules validate counts, values, and statuses. Not every table needs the same depth. Prioritize data that drives decisions or financial effects, not the table that is easiest to test.
In the visual, a duplicate breaks uniqueness and the total. A missing ID breaks identity completeness. Data 25 hours old violates the example 24-hour SLA even if the amounts are perfect. “Valid” needs to name the dimension that was checked. Quality is not one on/off switch for every need.
Reconciliation needs comparable coverage.
The source and warehouse need matching cutoffs, timezones, statuses, currencies, and refund treatment. A source that is still changing should not be compared with an old snapshot without noting the difference. Use a repeatable interval. Break down discrepancies by partition and event until the cause is known.
In the local example, the source total is Rp180,000 across three IDs. If the sink is Rp220,000, trace repeated IDs before blaming SUM. If the total matches but IDs differ, the aggregate is not enough. One missing record can be numerically hidden by another duplicate with the same amount.
Alerts need an owner and an action.
An alert should explain affected data, the failed check, the last healthy time, and how to investigate. Decide whether the pipeline stops, publishes a provisional result, or quarantines rows. A notification channel without an owner just turns an issue into office background noise.
Thresholds need context. A spike during a promotion may be legitimate. A small drop in a stable reference table may be dangerous. Start with clear invariants, then add anomaly detection for behavior that changes. Evaluate false alarms alongside missed incidents. A test that everyone ignores is not an effective control.
Attack a small example when the model changes.
Fixtures should include a refund, a legitimate null, a duplicate key, and late arrival. Compare old and new results over a limited scope. Simulate an upstream dependency failing: does downstream still publish a number as if it were complete? A successful query does not prove every required input was available.
Add defects that escaped as regression cases. Measure detection time, recovery time, and incorrect results that were consumed. Quality becomes tangible when the team finds issues faster and knows what to do next, not when a settings page has the highest test count.
An example to inspect.
-- The query returns violations
SELECT order_id, line_id, COUNT(*) AS n
FROM order_items GROUP BY order_id, line_id
HAVING COUNT(*) > 1;
-- Reconcile totals using the same cutoff.
The total matches, but one ID is missing and another ID with the same amount is duplicated. Is total reconciliation enough?
No. Check identity and coverage as well as aggregates. Errors can cancel each other out numerically.
Keep these three things.
- Connect tests to business failure modes.
- Align cutoffs and reconciliation definitions.
- Give every alert an owner and an action.
Sources, not slogans.
Primary references reviewed on 7 November 2026. The explanation, examples, and visual were prepared by RapiApp. The diagram simplifies the topic for learning. The article explains its assumptions and limits.
- dbt: Data tests
- PostgreSQL: Constraints
Continue the foundations.
- The JOIN worked. The numbers quietly multiplied.
- Conversion at 50% or 82.7%? Both are showing up in the meeting.
- All tests are green. Why is the report still wrong?