System Design · medium

How do you ensure data quality in a pipeline?

Asked in Analytics Engineer interviews, in the System Design round.

Short answer

Schema tests, freshness/volume checks, anomaly detection, contracts, alerting (e.g., dbt tests).

How to answer it

Test at every boundary, alert on the tests, and make the tests part of the pipeline so bad data stops rather than flows.

The layers:

# dbt: the tests that catch most real incidents
models:
  - name: fact_orders
    columns:
      - name: order_id
        tests: [unique, not_null]
      - name: customer_key
        tests:
          - relationships: {to: ref('dim_customer'), field: customer_key}

Then the organisational part: an owner per dataset, alerts routed to that owner, and a rule that a failed test blocks downstream models rather than warning into a channel nobody reads. Data quality is a property of the process, not a dashboard of red and green.

Related questions

Practice this for real