How do you validate values against a controlled vocabulary, reference data, and range or domain rules?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
How do you validate values against a controlled vocabulary, reference data, or predefined business rules such as range and domain checks?
As an example, picture a pipeline that loads order records (a status, a country code, a customer age, an order date, a list price and a discount) into an analytics table. Describe the checks you would run, how you would implement them, and what you would do with records that fail.
```hint Normalize before you compare
Think about which harmless formatting differences would make a valid value fail a membership test.
```
```hint Watch the missing values
Check how a NULL or NaN behaves in each kind of check, in both SQL and pandas. Does it pass, fail, or vanish?
```
### What a Strong Answer Covers
- Domain checks against a fixed allowed set, including normalization before the comparison
- Reference data checks against an authoritative table, and how unmatched values are found
- Range, date and length checks, plus cross-field business rules
- Where the checks run (ingestion, a pipeline step, database constraints) and how missing values are treated
- What happens to failing records: flagging, quarantine, batch-level thresholds and monitoring
### Follow-up Questions
- A new status value starts showing up in 5% of records overnight. What do you do?
- How do you validate a product ID against reference data that changes over time?
- When would you fail the whole batch, and when would you load it with the bad rows flagged?
- How would you choose the bounds for a range check on a field like transaction amount?
Overview: Asks how to validate data values against an allowed vocabulary, a reference table and business rules such as range and domain checks. Tests practical data cleaning skills: normalization, anti-joins, NULL handling, database constraints and what to do with records that fail.