How do you ensure data integrity and quality in your data pipelines?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
How do you ensure data integrity and quality in your data pipelines?
```hint Follow a bad record
Pick one kind of bad data, such as a duplicated order, and trace where in the pipeline it could enter and where you would catch it.
```
```hint Reruns and partial failures
Ask what happens to the target table if a job fails halfway through or runs twice for the same day.
```
### Clarifying Questions to Ask
- Is the pipeline batch, streaming, or both?
- Who consumes the output, and is late data or wrong data worse for them?
- How large are the tables, and how long does each run have to finish?
- Do upstream teams own their schemas, or can the pipeline agree on contracts with them?
### What a Strong Answer Covers
- Checks at every stage boundary, with the kinds of checks named (schema, uniqueness, nulls, references, ranges)
- Idempotent and atomic writes, so reruns and failures leave a clean state
- Reconciliation against the source
- Monitoring, alerting and lineage, so problems are found and traced
- What happens to failing records, and how the severity of a failed check is decided
### Follow-up Questions
- How would you catch a problem that passes every schema and constraint check, such as a unit change in an amount column?
- How do you decide whether a failed check should block the pipeline or only alert?
- How would these checks change for a streaming pipeline?
- How would you make a 90-day backfill safe to run?
Overview: Asks how you keep data correct and complete as it moves through a data pipeline. Tests validation at stage boundaries, constraint tests, idempotent writes, reconciliation against the source, and monitoring that catches problems before consumers do.