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.

- 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:
| Quality Dimension | What It Verifies | dbt / SQL Implementation Example | Severity Action on Failure |
|---|---|---|---|
| 1. Primary Key & Uniqueness | Zero duplicate surrogate keys or fan-out joins | `dbt` schema test: `unique` + `not_null` on `order_item_sk` | `ERROR` — Block publish immediately |
| 2. Referential Integrity | Every `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 Invariants | Financial & domain rules hold (`net_amount >= 0`, `status IN (...)`) | Custom singular `dbt` test asserting `SUM(debit) = SUM(credit)` | `ERROR` — Quarantine offending records |
| 4. Freshness & SLA Latency | Upstream 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 Drift | Today'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:
[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.
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
Continue Reading in This Topic Cluster
All 73 Guides
dbt (data build tool) + Apache Airflow in Production: Incremental Models, SCD Type 2 Snapshots & DAG Orchestration
How modern data teams combine Apache Airflow scheduling with dbt SQL transformations, automated schema testing, and Slowly Changing Dimension (SCD Type 2) history tracking.

Data Modeling for Data Engineers in 2026: Kimball Star Schema vs Snowflake Schema vs One Big Table (OBT) in Cloud Lakehouses
Why writing PySpark and dbt code without mastering Grain, Fact tables, Conformed Dimensions, and SCD Type 2 fails every Data Engineering System Design interview.

Change Data Capture (CDC) Architecture Explained: Streaming PostgreSQL & MySQL to Databricks & Snowflake with Debezium & Kafka
Why nightly `SELECT * WHERE updated_at > yesterday` batch jobs miss hard deletes and overload production OLTP databases—and how Log-Based CDC works.

