Data Quality and Validation Questions
Ensuring correctness and trust in data: validation rules, constraints, completeness/accuracy/timeliness checks, and quality frameworks. Covers designing validation into pipelines, quality gates before publishing, and handling edge cases and real-world dirty data. Central to any data engineering or analytics role.
Late-arriving records (for example a payment or event that lands hours or days after its event time) can invalidate already-computed daily aggregates. Design a safe backfill and reconciliation strategy: how you detect that a historical aggregate needs correcting, how you reprocess without corrupting concurrently-running dashboards, how you preserve an audit trail of the correction, and how you decide when a metric is "final enough" to stop reprocessing versus always remaining provisional.
Sample Answer
Direct answer
Late-arriving records that have already been aggregated into a published daily figure require a deliberate backfill and reconciliation strategy: detect that a historical aggregate needs correcting, reprocess it without corrupting anything currently being read, preserve an audit trail of the correction, and decide explicitly when a metric stops being reprocessed and is considered final.
Structured elaboration
- Detection: compare the count or sum of records for a given historical partition now against what was originally published; a meaningful positive delta signals late arrivals that were missed the first time.
- Safe reprocessing: recompute the affected partition into a new location (a versioned table or a staging area) rather than updating the live, currently-queried table in place, then atomically swap it in once validated, so no consumer ever reads a partially-updated, inconsistent intermediate state.
- Audit trail: record what changed, when, and by how much for every backfilled partition, both for internal debugging and so a consumer who cached or exported the earlier figure can understand why it changed.
- Deciding "final enough": define an explicit close window (for example, a day's metric is finalized 48 hours after day-end and will not be silently revised after that point, only explicitly corrected via an incident process if a later problem is found) rather than leaving every historical number implicitly provisional forever, which makes reproducibility impossible for anyone building on it.
Worked example
A payments event arrives 3 days late due to a retry-queue backlog on the source system, after the daily revenue figure for that date has already been published and consumed by a downstream forecasting model. The reconciliation job detects the delta (source total now exceeds warehouse total for that date beyond tolerance), recomputes the affected day into a versioned staging table, validates the new total against the source, and atomically swaps it into the live table, along with a logged correction note ("2026-07-01 revenue revised from $142,300 to $142,850 due to late-arriving events, corrected 2026-07-04") that the forecasting team can see and account for. This correction lands 3 days, 72 hours, after publication, past the 48-hour close window described above, so it is explicitly routed through the incident-correction process, not treated as routine same-day reconciliation: the correction note itself is the artifact that process requires (what changed, by how much, and why), and the forecasting team's downstream model is expected to explicitly account for a post-close-window revision rather than assume the figure was final and stable, which is exactly the distinction the close-window rule exists to make legible to consumers.
Trade-offs and pitfalls
The tension is between correctness (waiting longer before finalizing catches more late arrivals) and reproducibility/trust (a number that keeps silently changing weeks after publication erodes confidence in every number the pipeline produces). The practical resolution is an explicit close window with an above-normal-effort exception process for anything after it, not an indefinitely-open "we'll fix it whenever we notice," which optimizes purely for correctness at the cost of anyone being able to trust a number as stable.
Design a CI/CD workflow that gates deployment of ETL/dbt/Airflow code changes on data-quality tests. Cover: unit tests for individual transformation functions, integration tests against a small synthetic fixture dataset with known expected output, a snapshot-based regression test that fails a merge when a metric's historical values shift unexpectedly, and how you keep the fast pull-request suite separate from a slower nightly full-data run. What should block a merge versus only warn?
Sample Answer
Direct answer
A CI/CD (continuous integration, continuous deployment) workflow for data-quality-gated ETL (extract, transform, load) deployment needs three test tiers, unit tests on individual transformation functions, integration tests against a small synthetic fixture with a known expected output, and a snapshot-based regression test that catches unexpected shifts in a metric's historical values, with the fast tiers running on every pull request and the slowest, full-data tier running separately on a nightly schedule.
Structured elaboration
- Unit tests: test individual transformation functions in isolation (a date-parsing function, a deduplication function) against hand-crafted inputs including edge cases; these are cheap enough to run on every single pull request without slowing anyone down.
- Integration tests: run the actual pipeline (or a meaningful slice of it) against a small, version-controlled synthetic fixture dataset with a known, hand-verified expected output; these catch bugs in how transformations compose together, not just individual function correctness, and should still be fast enough to run on every pull request.
- Snapshot-based regression tests: run the pipeline against a stable reference dataset and compare the output metrics to a previously-approved snapshot; if a change shifts a historical metric's value unexpectedly (outside a small allowed tolerance for legitimate nondeterminism), the build fails and requires explicit review, which is what catches the class of bug where a change is individually correct but has an unintended side effect on an unrelated metric.
- Fast versus slow separation: unit and integration tests against small fixtures run on every pull request and should stay fast enough that engineers never feel discouraged from running them locally; the full-data nightly run validates against production-scale volume and catches issues (performance regressions, edge cases only present at real scale) the fast suite cannot.
Worked example
A change to the deduplication logic passes its unit tests (the function correctly dedupes a hand-crafted set of records) and its integration test (the pipeline produces the expected row count on the fixture dataset), but the snapshot regression test flags that the change shifts the historical monthly_active_users metric on the reference dataset by 3%, an unintended side effect nobody anticipated because the dedup change also happened to touch a shared join key. The regression test blocks the merge until a human explicitly confirms the shift is intended, which is exactly the class of bug the first two test tiers, by design, cannot catch on their own.
Trade-offs and pitfalls
What should block a merge versus only warn: unit and integration test failures should always block, since they represent a concrete, unambiguous correctness bug. A snapshot regression test failure should warn and require explicit human sign-off rather than auto-blocking, because sometimes the metric shift IS the intended outcome of the change, and a hard block here would force engineers to routinely bypass the check, training the team to ignore it. The design failure to avoid is making the fast suite too comprehensive, if unit and integration tests take fifteen minutes instead of two, engineers start skipping local runs and relying on CI alone, which slows the whole feedback loop down.
You operate a pipeline ingesting on the order of a million events per minute. Define a concrete, justified set of operational data-quality metrics and alert thresholds you would instrument: ingestion lag/freshness, row-count deltas versus an expected baseline, null-rate spikes, schema-change events, and duplicate rate. For each metric, state a starting alert threshold and severity tier, and explain how you would distinguish a real regression from normal day-to-day variance.
Sample Answer
Direct answer
For a pipeline ingesting on the order of a million events per minute, the concrete operational metrics to instrument are ingestion lag/freshness, row-count deltas against an expected baseline, per-column null-rate spikes, schema-change events, and duplicate rate, each with a starting severity tier that distinguishes a real regression from ordinary day-to-day variance.
Structured elaboration
- Ingestion lag: time between event occurrence and it landing queryably; alert if lag exceeds a threshold sustained for several consecutive minutes, not on a single spike, to avoid paging on a transient blip.
- Row-count delta: compare the current window's row count against a rolling baseline (a trailing 7-day median for the same time-of-day/day-of-week, not a flat average, since volume has strong seasonality); alert on a large relative deviation, for example more than 3x the typical day-to-day variance.
- Null-rate spike: track per-column null rate over time and alert when a critical column's null rate jumps materially above its historical baseline, since a sudden jump is a much stronger signal of a real upstream break than a stable-but-nonzero baseline null rate.
- Schema-change events: alert on any unexpected added, removed, or type-changed column, since even a seemingly benign addition can break a strict downstream consumer.
- Duplicate rate: track the rate of exact or near-duplicate records and alert on a sustained increase, which is usually a symptom of a retry storm or a broken idempotency guarantee upstream.
Worked example
At this ingestion volume, a severity tiering that works well in practice: freshness lag over 5 minutes = warning (page only if sustained 15+ minutes), row-count delta over 3x the typical day-of-week variance = page immediately, any unexpected schema change on a table with more than 5 known downstream consumers = page immediately, null-rate spike over 5 percentage points above the 7-day baseline on a required field = page, duplicate rate above 2x baseline = warning.
Trade-offs and pitfalls
The recurring failure mode at this scale is comparing against a flat, non-seasonal baseline: a naive "alert if today's count differs from yesterday's by more than X%" fires constantly on legitimate day-of-week seasonality (weekends are naturally lower volume for most consumer products) and trains the on-call team to ignore the alert channel entirely. A seasonality-aware baseline, even a simple trailing-median-by-day-of-week, removes most of that noise and is usually a bigger improvement to signal quality than tightening or loosening the raw threshold.
What key data-quality metrics would you monitor for both a training dataset and the corresponding production input data feeding a deployed model: and for each metric you propose, explain what specific problem it catches and give a reasonable starting alert threshold, and describe the overall gate you would build (schema, null/type, range, duplicate, and drift checks) before data is used to train or score a model.
Sample Answer
Direct answer
For both a training dataset and the corresponding production input data feeding a deployed model, monitor completeness, null rate, uniqueness/duplicate rate, cardinality, basic distributional statistics (mean, standard deviation), and a stability metric such as Population Stability Index (PSI), because each catches a distinct failure mode a model can silently degrade from, and each needs its own reasonable starting alert threshold since a threshold that is right for one metric is meaningless for another.
Structured elaboration
- Completeness and null rate: catches missing or partially-broken upstream data before it silently reduces the model's effective feature signal, or before an unexpected NULL propagates into a feature pipeline that was not built to handle it. A reasonable starting threshold is to block training on any required field exceeding a 1% null rate, and in production, to alert if a field's null rate more than doubles relative to its own trailing 7-day baseline, since a fixed absolute threshold alone would miss a meaningful jump between two values that both still look individually low.
- Uniqueness/duplicate rate: catches duplicated training examples (which can bias a model toward whatever pattern the duplicated rows represent) and, in serving, duplicated inference requests that can distort aggregate monitoring metrics if not deduplicated. A reasonable starting threshold is to block training if the exact-duplicate rate exceeds 0.5% of rows, and to alert (without blocking) if the production duplicate-request rate deviates by more than 3x from its own trailing baseline.
- Cardinality: a sudden jump in the number of distinct values for a categorical feature (a new, previously-unseen category flooding in) is often the first visible symptom of an upstream encoding or join-key bug, well before it manifests as a model performance drop. A reasonable starting threshold is to alert on any single-day increase of more than 20% in the number of distinct values relative to the cardinality observed at last training time.
- Distributional statistics and PSI: catch the case where individual records are all individually valid, but the population as a whole has shifted, exactly the class of problem raw validity checks cannot see, since every single value can pass its own range check while the aggregate distribution has moved meaningfully. The standard, widely-used starting bands are a soft warning at PSI above 0.1 and a hard alert at PSI above 0.25, treating anything below 0.1 as normal variation. PSI is computed by first splitting the feature's range into the same fixed buckets for both the baseline (training) and current (production) distributions, then, for each bucket, taking the difference between the current and baseline percentage of rows in that bucket, multiplying it by the natural log of their ratio, and summing across buckets: PSI=∑i(currenti−baselinei)×ln(baselineicurrenti). Concretely, for a feature split into 4 buckets where the baseline (training) distribution is 30%, 25%, 25%, 20% and the current (production) distribution has shifted to 20%, 30%, 25%, 25%: the per-bucket contributions are (0.20−0.30)ln(0.20/0.30)≈0.0405, (0.30−0.25)ln(0.30/0.25)≈0.0091, (0.25−0.25)ln(1)=0, and (0.25−0.20)ln(0.25/0.20)≈0.0112, summing to PSI≈0.061, below the 0.1 soft-warning band despite a visible shift in where the mass of the distribution sits.
- Schema and type violations: unlike the rate-based metrics above, these warrant zero tolerance as a starting threshold, since a type mismatch or a missing required column is an unambiguous break rather than a rate to tune.
- The overall gate: schema, null/type, range, and duplicate checks should run and block before data is used to train, using the zero-tolerance and rate thresholds above, and a lighter-weight subset of drift checks (cardinality and PSI) should run continuously against production inputs, using the same starting thresholds, to catch degradation between training runs.
Worked example
A recommendation model's training data has a categorical device_type feature with 12 known values at training time; in production, cardinality monitoring detects it has grown to 40 distinct values within a month, a 233% increase that clears the 20% starting-threshold by a wide margin, most of them new device-model strings from a hardware vendor's recent product launch that the training encoding never saw. This is caught by the cardinality check well before it would show up as a measurable model-quality regression, giving the team time to retrain or add a fallback encoding for unseen categories before performance actually degrades.
Trade-offs and pitfalls
The recurring mistake is monitoring only the training dataset once, at training time, and never continuously monitoring the production input stream against that same baseline; a model that was trained on genuinely high-quality data can still degrade in production purely because the input distribution has drifted, which is invisible unless the same quality and drift checks that gated training are also run continuously, on a schedule, against live production inputs. A second common mistake is treating every starting threshold above as permanent rather than a first cut to be tuned against the specific feature's observed false-positive rate once real alert history accumulates.
You have limited engineering capacity and a backlog of data-quality issues with varying severity and varying business impact, and multiple teams are each requesting their own fix be prioritized first. Describe a prioritization framework you would use to decide what to work on next, and how you would build cross-team alignment and commitment for a shared solution (for example a common validation framework) rather than everyone patching their own pipeline independently.
Sample Answer
Direct answer
With limited engineering capacity and a backlog of data-quality issues of varying severity, prioritize using a framework that weighs business impact, likelihood of recurrence, and ease of fix together, rather than working purely by reported severity or purely by whichever issue is loudest, and build cross-team alignment around a shared solution by making the cost of NOT solving it collectively visible to everyone who would otherwise keep patching their own symptom independently.
Structured elaboration
- Prioritization framework: score each issue on business impact (revenue, trust, or compliance risk if unaddressed), likelihood of recurrence (a one-time fluke versus a systemic pattern likely to keep causing incidents), and ease of fix (quick win versus multi-quarter investment), and use the combination, not any single dimension alone, since a high-impact-but-nearly-impossible-to-fix issue and a low-impact-but-trivial-to-fix issue both deserve very different treatment than a mid-impact, systemic, moderately-hard-to-fix issue that might actually be the highest-leverage item on the list.
- Building cross-team alignment: when multiple teams each want their own fix prioritized, the highest-leverage move is often identifying that several teams' individually-requested fixes are actually symptoms of the same underlying, systemic root cause (a shared schema-registry gap, a missing common validation framework); making that shared root cause visible reframes the conversation from "whose fix goes first" to "let's jointly fund the one fix that helps everyone," which is a fundamentally easier negotiation.
- Getting commitment without direct authority: bring data, not opinions, to the prioritization conversation (quantified incident counts, quantified business impact per team) and let the shared, objective picture do the persuading, rather than relying on personal influence alone.
Worked example
Three different teams each separately request their own data-quality fix be prioritized this quarter. Digging into the actual root cause of all three reveals they all stem from the same underlying gap: no shared schema-registry enforcement across producer teams. Reframing the ask from three competing, team-specific requests into one shared infrastructure investment, with each team's incident history used as concrete evidence of the collective cost of not fixing it, turns three competing priorities into one aligned, jointly-funded initiative that serves all three teams' actual underlying need. Scoring this alongside two other backlog items on a simple 1 (low) to 3 (high) scale per dimension, and summing the three scores, makes the trade-off concrete rather than just narrated:
| Issue | Business impact | Recurrence likelihood | Ease of fix | Total score |
|---|---|---|---|---|
| Shared schema-registry gap (all 3 teams) | High (3) | High (3), systemic | Hard (1), multi-quarter | 7 |
| One-time vendor bad-file incident | Medium (2) | Low (1), a fluke | Easy (3), quick patch | 6 |
| Cosmetic dashboard label bug | Low (1) | Low (1) | Easy (3), quick patch | 5 |
The schema-registry gap wins the priority order (7, then 6, then 5) precisely because it combines high impact with high recurrence, even though it is the hardest of the three to fix, which is the case the framework is built to catch: scoring on ease of fix alone would have wrongly ranked the two quick patches above the systemic, harder, but far higher-leverage fix.
Trade-offs and pitfalls
The temptation under pressure is to simply work the backlog in the order requests arrived, or to prioritize whichever team is loudest, both of which systematically under-invest in quieter-but-higher-leverage systemic fixes in favor of whoever advocates hardest for their specific, narrower issue. A framework that explicitly scores business impact and recurrence likelihood, and actively looks for shared root causes across seemingly-separate requests, protects against exactly that bias.
Unlock Full Question Bank
Get access to all 39 Data Quality and Validation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.