In a batch ingestion pipeline, what is schema drift and why does it break loads?
answer
- the source changed and nobody told you
- columns come, go, and change type
- yesterday's shape meets today's file
- the failed load is the lucky case
- some drift is loud, some is silent
basics
~10 sSchema drift is the source changing shape without warning: columns added, dropped, renamed, retyped or reordered. Loads written against yesterday's shape then fail on a cast, shift positionally, or silently drop the new field.
solid answer
~50 sSchema drift is the gap that opens when a source system evolves its structure and the ingestion job downstream does not evolve with it. It shows up as five shapes: a **new column**, a **dropped column**, a **rename**, a **retype** (integer becomes free text, date becomes string), and a **reorder** of positions. The reason it breaks loads is that an extract-and-load job encodes an assumption about the source — a column list, a target DDL, a positional CSV layout — and nobody in the source team is obliged to check that assumption before shipping a migration. Some drift is loud: the load fails on an unknown column or a bad cast, and you get paged. The dangerous kind is quiet: a new column never lands because your projection never asked for it, or a dropped column keeps loading as NULL and dashboards drift with it.
go deeper
Be ready to name the shapes of drift — added, dropped, renamed, retyped, reordered columns — and give one concrete example of a load breaking because of each.
Explain why an added column and a dropped column produce opposite symptoms depending on whether the extract uses an explicit column list or a wildcard, and where each is detected.
Show that you rank silent corruption above loud failure and describe the detection you would put in place — schema diffs against a stored snapshot, per-column null-rate monitors, row-shape assertions.
Own the framing that drift is an organisational boundary problem: two teams, two release schedules, no handshake. Talk about which sources deserve strict treatment and who is accountable when a change breaks a downstream number.
## What schema drift is Schema drift is the accumulated difference between the shape a source system produces **today** and the shape your ingestion job was written against. It is not a bug in your code and not a bug in theirs — it is the normal consequence of two systems owned by two teams changing on two schedules. An application team adds a column because a feature needed it; nobody involved in that change was thinking about the nightly extract that reads the table. The word "drift" is apt because the divergence is usually gradual and often invisible until something downstream is obviously wrong. ## The five shapes of change **Added column.** The most common and, superficially, the most harmless. If your extract names its columns explicitly, the new one simply never arrives — no error, no data. If your extract is `SELECT *` into a fixed target, the load fails because the target has no place to put it. **Dropped column.** The source stops producing a field. An explicit column list turns this into a loud failure at the source query ("column does not exist"). A wildcard extract into a permissive target usually just stops filling that column, and it quietly becomes all NULLs. **Renamed column.** The hardest to classify, because to any automated comparison a rename is indistinguishable from one drop plus one add. The data is still there; the lineage is broken. **Retyped column.** An integer becomes a string because someone started storing `"N/A"`; a date column becomes a timestamp; a numeric widens to accommodate a bigger range. Widening (integer to bigint, numeric to string) is survivable; narrowing loses data or fails on the first value that doesn't fit. **Reordered columns.** Irrelevant if you load by name, catastrophic if you load positionally — a header-less CSV or a fixed-width file that gained a column in the middle will write every subsequent value into the wrong target column. ## Loud failures and silent ones The instinct is to treat a failed load as the bad outcome. In practice a failed load is the *good* outcome: it is loud, it is timestamped, and someone investigates it that morning. The expensive failure is the one that succeeds. A new revenue column that never lands means a finance dashboard is under-reporting and no alert fires. A dropped `status` column loading as NULL means every downstream filter on `status = 'active'` returns nothing, and the first symptom is a business user asking why a number went to zero — weeks later, with the raw evidence already overwritten. This asymmetry is why most mature ingestion designs deliberately convert silent drift into loud drift: explicit projections, recorded expected schemas compared each run, per-column null-rate monitors, and row-shape assertions. ## Why batch ingestion is especially exposed A batch job runs on a schedule against whatever the source looks like at that moment. It has no notification channel from the source, no handshake, and typically no record of what the source looked like last time unless you built one. It also runs unattended at 3am, which is when the gap between "it broke" and "someone noticed" is longest. File-based sources make it worse: a CSV or JSON drop has no enforced schema at all, so the file that arrives tomorrow can differ from today's in any way the producer likes, including a header row that quietly changed. ## Where drift gets detected There are three practical detection points, and good pipelines use more than one. **At extract time**, by reading the source's own metadata (an information-schema query, a file header, an API's declared response shape) and diffing it against a stored copy from the previous successful run. This is the only point that catches added columns you are not selecting. **At load time**, when a cast fails or the target rejects an unknown field. Cheap, but it only catches the drift that happens to be incompatible with the target. **After load**, through data-quality checks on the landed rows: null rates per column, distinct-value counts, row counts against the previous run. This is the safety net for drift the first two missed. ## What "handling" drift actually means Handling is not the same as tolerating. A pipeline that accepts anything and lands it has moved the problem downstream, not solved it. The working definition of a well-handled pipeline is: **every schema change is either applied deliberately or surfaced to a human quickly, and none of them lose data quietly.** Which of those two branches a given change takes — auto-evolve the target, or halt and alert — is the real design decision, and it depends on whether the change is additive or destructive and on how much blast radius sits downstream of the table.
- Why is a new column often more dangerous than a change that fails the load outright?Because it usually fails nothing. An explicit column list simply never asks for it, so the field lands nowhere and no alert fires. The pipeline reports success while the warehouse is missing a fact that the business may already be acting on. A failure, by contrast, gets investigated the same morning.
- Which single drift event is hardest for an automated detector to classify correctly, and why?A rename. Comparing two column lists shows one name gone and one name new, which is exactly what a drop plus an unrelated add looks like. Without a stable identifier or a heads-up from the producer, the detector cannot tell whether history should be carried forward into the new name or the old column genuinely retired.
- Does landing files as semi-structured data remove the drift problem?No, it relocates it. Storing the raw payload means nothing is lost at ingest, which is genuinely valuable, but every consumer that projects a typed field out of it still breaks when that field disappears or changes type. You have traded an ingest-time failure for a read-time one, spread across more places.
It is like a shared spreadsheet where a colleague inserts a column overnight: your formulas still calculate, they just now point one cell to the left.
saying these in an interview costs you the question
- Says drift only means new columns being added
- Treats a failed load as worse than a silently wrong one
- Claims a rename is trivially detectable by tooling
- Assumes the source team will always announce migrations
- Thinks landing raw JSON makes drift stop mattering