Uncorp
Log In
Data Engineering4 min readUpdated 2026-10-27

Data Quality & Pipeline Observability: Preventing Broken Dashboards with dbt Tests, Write-Audit-Publish (WAP) & Data Contracts

Nothing destroys a Data Engineer's credibility faster than the CFO spotting a broken revenue number before your team does. Learn the Write-Audit-Publish pattern.

Naitik Tailor & Uncorp Engineering Faculty
Write-Audit-Publish (WAP) Data Quality Gate with dbt Tests & Airflow Orchestration
TL;DR — Key Engineering & Career Takeaways
  • In naive ETL pipelines, transformations write directly into production Gold tables and run quality checks *afterwards*—meaning executives see corrupted metrics for hours while engineers scramble to roll back.
  • The **Write-Audit-Publish (WAP)** pattern stages transformed data in an isolated branch or staging schema (`Write`), executes automated quality assertions (`Audit`), and atomically swaps or merges into the production Gold table only if 100% of critical checks pass (`Publish`).
  • For row-level anomalies (e.g., 12 malformed records out of 10 million), use a **Quarantine / Dead-Letter Table** splitter so valid rows proceed on schedule while bad rows trigger an alert with diagnostic metadata.

1. The 5 Dimensions of Automated Data Quality Checks

Testing `WHERE id IS NOT NULL` is only 10% of production data quality. Senior data engineers implement five layers of assertions across Bronze, Silver, and Gold tables:

5-Layer Production Data Quality Assertion Matrix
Quality DimensionWhat It Verifiesdbt / SQL Implementation ExampleSeverity Action on Failure
1. Primary Key & UniquenessZero duplicate surrogate keys or fan-out joins`dbt` schema test: `unique` + `not_null` on `order_item_sk``ERROR` — Block publish immediately
2. Referential IntegrityEvery `customer_id` in `fct_orders` exists in `dim_customers``dbt` `relationships` test (`to: ref('dim_customers'), field: customer_id`)`ERROR` or route orphan key to Inferred Member placeholder
3. Business Domain InvariantsFinancial & domain rules hold (`net_amount >= 0`, `status IN (...)`)Custom singular `dbt` test asserting `SUM(debit) = SUM(credit)``ERROR` — Quarantine offending records
4. Freshness & SLA LatencyUpstream source tables updated within expected window`dbt source freshness` (`warn_after: 2 hours, error_after: 4 hours`)`WARN` / `ERROR` — Halt downstream DAG & page on-call
5. Volume & Distribution DriftToday's row count or null rate did not unexpectedly drop by 80%7-day rolling z-score anomaly check on daily row count & average order value`WARN` / `ERROR` — Prevent silent partial loads

2. Implementing the Write-Audit-Publish (WAP) Pattern in Airflow + dbt

Here is how Write-Audit-Publish prevents bad data from ever polluting your BI dashboards:

Write-Audit-Publish (WAP) & Quarantine Splitter Workflow
[Step 1: WRITE]  ──► Airflow triggers `dbt build --select tag:silver` into staging table / Delta commit
   ├─► Valid rows (pass row-level rules)   ──► `silver.orders_staged`
   └─► Malformed rows (e.g., negative price) ──► `quarantine.orders_dlq` (with failure_reason & batch_id)
[Step 2: AUDIT]  ──► Execute table-level dbt assertions (uniqueness, volume drift, reconciliation)
   ├─► IF AUDIT FAILS -> Abort DAG, alert Slack/PagerDuty, keep yesterday's Gold table untouched
   └─► IF AUDIT PASSES -> Proceed to Publish
[Step 3: PUBLISH] ──► Atomically promote/merge into `gold.fct_orders` & trigger BI cache refresh

3. Handling Upstream Schema Drift Without 3 AM Pipeline Outages

Upstream backend teams frequently add new columns or rename JSON fields in microservices without warning the data team. To prevent 3 AM DAG crashes: (1) Establish **Data Contracts** (JSON Schema / Protobuf validation at the API/Kafka producer boundary), and (2) Configure Databricks Auto Loader / Spark with `rescuedDataColumn` (`_rescued_data`) so unexpected new fields or type mismatches are captured safely in a JSON column in Bronze without failing ingestion.

Frequently Asked Questions

What is the difference between `dbt test` and `dbt build` in production DAGs?

Running `dbt run` followed by `dbt test` builds *all* downstream Gold models first and only runs tests at the very end—meaning a broken Silver table still propagates corrupted data into Gold. Running `dbt build` executes models and their schema/data tests in DAG topological order: if a Silver model fails its test, `dbt build` immediately skips building dependent Gold models.

Where can I learn production dbt testing, Airflow orchestration, and Lakehouse reliability?

These exact patterns are taught hands-on in Uncorp's Data Engineering Module 3 (Spark, Databricks, Airflow, Kafka & dbt) and our comprehensive 120-hour Data Engineering Master Program.

Written & Reviewed By Uncorp Engineering Faculty

Naitik Tailor & Uncorp Engineering Faculty

Founder & Principal Engineering Mentors (12+ Yrs Enterprise Experience) · VIT CSE '21 · Symbiosis MBA '24 · Ex-Delhivery & Ex-Aditya Birla Capital

About Uncorp

Continue Reading in This Topic Cluster

All 73 Guides