Data Governance, Contracts, and Classification Questions
Governing data at scale: data contracts between producers and consumers, schema evolution/compatibility, data classification and sensitivity tagging, access control, and lineage/cataloging. Covers policy, ownership, and compliance-driven controls over data. The governance layer over the technical stack.
Design an approach to capture and expose lineage across a realistic BI ecosystem: Airflow-orchestrated ETL, ad-hoc SQL run directly in a BI tool, and Python scripts writing to the warehouse. Name at least two concrete methods to capture lineage in practice (for example dbt's built-in lineage, SQL query parsing, or runtime metadata capture) and describe how you'd surface a 'why is this number X' trace, through dimension and fact schema and metric-definition changes, back to source events for a business user.
Sample Answer
Across a mixed BI (business intelligence) stack, no single capture method covers everything, so the practical approach combines at least two: parsing dbt's (a SQL-based data transformation tool) own lineage graph for anything modeled in dbt, SQL query parsing for ad-hoc queries run directly against the warehouse from the BI tool, and runtime metadata capture, logging actual read and write events, for Python scripts and Airflow-orchestrated ETL (extract, transform, load) jobs that are not expressible as parseable SQL. Surfacing a "why is this number X" trace for a business user means walking that combined lineage graph from the dashboard's metric definition down through the fact and dimension tables to the source events, and presenting it as a readable chain rather than the raw graph.
Capturing lineage across each part of the ecosystem
- Airflow-orchestrated ETL: capture at the task level via Airflow's (a workflow orchestration tool) lineage hooks, recording which task read which input and wrote which output, giving the coarse backbone of which pipeline stage touched which table.
- Ad-hoc SQL run directly in the BI tool: this is the trickiest case, since it bypasses the orchestrated pipeline entirely. SQL query parsing is the fit here: intercept or log the query text the BI tool sends to the warehouse, most warehouses expose a query history or audit log, and parse it the way a static SQL lineage tool would, extracting which tables and columns the query reads to produce the report or chart.
- Python scripts writing to the warehouse: these usually are not parseable SQL, so runtime metadata capture is the fit: the script, or a lightweight wrapper it calls, explicitly emits a lineage event describing what it read and wrote as it executes.
- Anything modeled in dbt: dbt's own manifest already encodes the model-to-model dependency graph from its reference and source declarations, and dbt's compiled SQL can be parsed for column-level detail, so dbt-managed transformations get lineage largely for free without a bespoke capture method, which is why it is worth naming as its own method distinct from generic SQL parsing.
Combining them
Each of the above methods emits events into one shared lineage store using a common event format, source, target, transformation, timestamp, regardless of which capture method produced it, so the resulting graph spans Airflow tasks, dbt models, ad-hoc BI queries, and Python scripts as one connected structure rather than several disconnected fragments a business user would have to mentally stitch together.
Surfacing a "why is this number X" trace for a business user
Start from the metric as defined in the BI tool, the aggregation and filter logic that turns fact-table rows into the number on screen, and walk backward: the metric definition traces to specific columns in a fact table, which trace through the fact table's build to the dimension tables joined into it, and further back through however many transformation steps the lineage graph records, down to the raw source events that ultimately fed all of it. Present this as a linear, plain-language chain for a non-technical user, for example "this number equals the sum of order amounts, filtered to active customers, from orders placed in the second quarter, sourced from the checkout event stream," rather than the raw dependency graph, with an option to expand any step for someone who wants the underlying SQL or transformation detail. Critically, the trace should also surface when the metric's definition itself changed, for example if "active customer" was redefined last quarter to use a longer lookback window, since a metric-definition change can move a number just as much as a data change can, and a business user asking "why did this change" needs both possibilities distinguished, not just the data lineage.
Worked example
A sales executive asks why "active customers" dropped 15% quarter over quarter on the dashboard. The trace starts at the metric definition: "active customers equals the count of distinct customers with an order in the trailing 90 days," which itself changed from a trailing 30-day window two months ago, visible because the metric's definition is versioned in the BI tool's semantic layer. That alone is a plausible full explanation, since a stricter window produces a smaller count on otherwise-identical data, so the trace surfaces the definition change prominently, dated, before walking any further into the data. The team also checks the data-lineage side to rule out a second cause: the metric traces to fct_orders, built by a dbt model giving exact column lineage for free, which joins dim_customer, populated by an Airflow-orchestrated ETL job, fed ultimately by the checkout event stream. No anomaly is found there; the ad-hoc query the BI tool runs directly against fct_orders for this specific dashboard tile is confirmed, via SQL-parsing of the warehouse's query log, to match the documented metric definition. The answer presented to the executive: the drop is fully explained by the intentional definition change to a stricter 90-day window, not a data quality issue, with the trace itself as the evidence.
Trade-offs and pitfalls
Ad-hoc SQL run directly against the warehouse from a BI tool is the hardest part of this ecosystem to keep in the lineage graph, since it happens outside any orchestrator; relying only on periodic query-log parsing means there is a lag between a new ad-hoc report going live and it appearing in the graph, and a query the BI tool caches instead of re-issuing might not show up in the log at all. The pitfall specific to this "why is this number X" use case is tracing only the data path and never checking whether the metric's own definition changed. A perfectly correct data trace can still mislead a business user if the real cause was a silent redefinition of what the metric means, so the trace has to surface metric-definition history as a first-class part of the answer, not an afterthought.
Your team is debating whether to enforce a strict schema at the source (producer contracts, schema-on-write) versus accepting loosely-structured data and applying schema on read in a raw lake. What are the real trade-offs (flexibility, coupling, how quickly you detect an upstream change, cost of fixing problems later), and what would a pragmatic hybrid look like for an organization with many independently-ingesting teams?
Sample Answer
Schema-on-write (a producer contract enforced before data lands) trades ingestion-time flexibility for early problem detection and stable downstream contracts; schema-on-read (loosely-structured ingestion into a raw lake, with structure applied when a query runs) trades that stability for the ability to ingest first and figure out structure later. Neither wins outright: the right choice tracks how tightly coupled the producer and consumer need to be, and a pragmatic hybrid applies schema-on-write only where the coupling cost is worth paying.
The real trade-offs
| Dimension | Schema-on-write | Schema-on-read |
|---|---|---|
| Flexibility for the producer | Low: a new field or type change requires a contract update and often a migration | High: producer can change shape freely, nothing downstream breaks at ingest time |
| Coupling | Producer and consumer are coupled through an explicit, versioned contract | Loosely coupled at ingest; coupling reappears implicitly wherever a query parses the raw structure |
| Speed of detecting an upstream change | Fast: a validation failure blocks the bad batch at the source, often before it's published | Slow: nothing breaks until a downstream query silently returns wrong or null values, sometimes weeks later |
| Cost of fixing problems later | Lower: the contract already documents what "correct" means, so root-causing a violation is quick | Higher: every consumer's ad hoc parsing logic may have quietly diverged, so a fix has to be re-verified against every downstream reader individually |
| Cost up front | Higher: someone has to define and maintain the contract before data flows | Lower: nothing to define before you can start ingesting |
The pattern worth internalizing: schema-on-read doesn't remove the cost of a schema mismatch, it defers and multiplies it. Every consumer ends up independently guessing at the same structure, and when the producer changes something, each of those independent guesses breaks separately and gets debugged separately instead of failing once at a clear boundary.
A pragmatic hybrid for many independently-ingesting teams
Apply schema-on-write only at the boundary that matters: where a producer's data crosses into shared, multi-consumer use.
- Raw landing zone, schema-on-read. Every team can dump data into a raw lake in whatever shape it naturally arrives, with minimal friction to ingest. This layer is explicitly NOT a contract; nothing downstream should query it directly for anything that matters.
- Curated layer, schema-on-write. Before data is exposed for cross-team consumption (a shared table, an event topic other teams subscribe to), it passes through a transformation that validates it against a versioned contract (types, nullability, semantic field definitions) and rejects or quarantines rows that don't conform. This is where the flexibility-versus-coupling trade-off actually gets paid, and it's paid once, by the producer, instead of N times by each consumer.
- Team-internal, exploratory data stays schema-on-read. A team doing its own internal exploration of its own raw data doesn't need a contract; the contract earns its cost only where a producer-consumer boundary crosses team lines.
This mirrors the general principle: schema-on-write cost should scale with fan-out. A table with zero or one downstream consumer rarely justifies a formal contract; a table feeding a dozen teams' pipelines almost always does.
Trade-offs and pitfalls
The common wrong turn is applying schema-on-write everywhere out of caution, which slows every team down for datasets nobody outside the producing team actually depends on. The opposite wrong turn is leaving genuinely shared, high-fan-out data schema-on-read indefinitely because "the lake is flexible"; that flexibility is exactly what lets an upstream rename silently propagate bad values into a dozen consumers' pipelines before anyone notices. The hybrid works only if there's a clear, enforced line between the raw landing zone and the curated layer; if teams are allowed to query raw data directly "just this once," the curated layer's contract stops actually protecting anyone.
Compare hashing, tokenization, and k-anonymity-style aggregation as ways to anonymize PII while still preserving enough utility for aggregation and geospatial or cohort analysis. When would you reach for a hashed surrogate key with a secure mapping table instead of one-way hashing, and what actually determines whether the result is still re-identifiable in practice?
Sample Answer
Hashing and tokenization protect an individual identifier's value while usually preserving the ability to join or count by it; k-anonymity-style aggregation protects the individual by construction, making a record indistinguishable from a group of others, at the cost of precision. Which one preserves enough utility for aggregation and geospatial or cohort analysis depends on whether the analysis needs to join back to a specific individual, or only needs group-level counts and patterns.
The three approaches
- One-way (irreversible) hashing. Apply a cryptographic hash function (for example SHA-256) to an identifier, typically with a secret salt appended before hashing, producing a fixed-length value that cannot be reversed back to the original. Two records with the same underlying identifier still hash to the same output, so joins and deduplication across datasets still work, but nobody holding only the hash can recover the original value.
- Tokenization. Replace the identifier with a randomly generated surrogate token, with the mapping between token and original value stored in a separate, tightly access-controlled vault. Unlike hashing, tokenization is reversible, but only by looking up the vault, not by any computation on the token itself.
- k-anonymity-style aggregation. Generalize or bucket quasi-identifiers (attributes that aren't identifying alone but can combine to identify someone, like ZIP code plus birth date plus gender) so that every combination of quasi-identifier values in the released dataset is shared by at least k records. A dataset satisfies k-anonymity for a given k if no row's quasi-identifier combination is unique among fewer than k rows.
When to reach for a hashed surrogate key versus a hashed-mapping-table (tokenized) approach instead of plain one-way hashing
Plain one-way hashing is the right default when the only need is consistent joinability or deduplication and the original value never needs to be recovered by anyone. Reach for tokenization (a reversible mapping held in a secure vault) instead specifically when there's a known, legitimate future need to re-identify a record, for example a fraud investigation, a customer service lookup, or a regulatory data-subject request, because a one-way hash offers no path back to the original value even for an authorized, audited purpose. The deciding question is not "is the data more or less sensitive" but "will an authorized party ever legitimately need the original value back": if yes, tokenize; if the value truly never needs to be recovered, one-way hashing is simpler, has no vault to secure or leak, and gives the same joinability.
What actually determines whether the result is still re-identifiable in practice
- Input entropy for hashing. A hash is only as hard to reverse as the input space is large. Hashing a low-entropy value like a US Social Security number's last four digits, or an email address drawn from a small guessable set, is vulnerable to a dictionary attack: an attacker just hashes every plausible candidate value and compares, which defeats the "irreversibility" of the hash entirely if there's no secret salt, or even with a salt if the salt itself leaks. A high-entropy identifier (a long random internal user ID) is much harder to attack this way.
- Salt secrecy and reuse. A shared, static salt reused across the whole dataset doesn't add entropy against an attacker who already has the salt; it primarily defends against a precomputed rainbow-table attack built before knowing the salt. Per-record or per-context salts are stronger but break the ability to join records by their hashed value, so there's a direct trade-off between hash strength and joinability.
- Auxiliary data linkage, for k-anonymity. k-anonymity's guarantee is only as good as the set of quasi-identifiers considered; a released dataset can satisfy k-anonymity on its own declared quasi-identifiers and still be re-identifiable if an attacker has an external dataset with additional overlapping fields (a classic example: combining a k-anonymized health record dataset with a public voter-registration list on ZIP code, birth date, and gender re-identifies specific individuals even though each field alone looked safely generalized). k-anonymity also says nothing about protecting the sensitive attribute itself when every member of a k-sized group happens to share the same sensitive value, a gap addressed by extensions like l-diversity, not by k-anonymity alone.
- Group size versus utility for geospatial/cohort analysis specifically. For location-based analysis, a small k or a fine-grained geographic bucket preserves useful spatial resolution but increases re-identification risk in sparsely populated areas (a rural ZIP code with very few residents can fail to genuinely protect anyone even at k=5, while the same k in a dense urban ZIP is comfortably anonymous); the safe group size is a property of the underlying population density, not a single k value that works everywhere.
Worked example
A dataset of 12 customer records has quasi-identifiers (3-digit ZIP prefix, age decade). Grouped by that pair: three records share (100, 30s), three share (100, 40s), and six share (200, 30s). Every group has at least 3 members, so this dataset satisfies k-anonymity for k=3: no combination of ZIP-prefix and age-decade is unique to fewer than 3 people. If the analysis instead needed 5-digit ZIP and exact age, the same 12 people would very likely each land in their own group (k=1), which is not anonymized at all; the generalization from 5-digit to 3-digit ZIP and from exact age to decade is precisely what raised k from 1 to 3, at the cost of losing that finer geographic and age resolution for the analysis.
Trade-offs & pitfalls
The recurring mistake is treating these as competing options to choose once, rather than layering them: a common, effective pattern is tokenizing direct identifiers for operational joinability, then additionally applying k-anonymity-style generalization to the quasi-identifiers before the dataset is used for broad cohort or geospatial analysis, since tokenization alone doesn't address the auxiliary-linkage re-identification risk that k-anonymity is specifically designed to reduce.
Data governance practices like access controls, lineage, and PII handling are often the first things deprioritized under deadline pressure. How would you make the case for investing in them anyway, and what's one low-friction first step you'd implement to start building the habit without asking for a big upfront commitment? If you've led an effort like this before, walk through what you actually did and what stuck.
Sample Answer
Direct answer
Make the case in terms the deadline-driven decision already respects: frame access controls, lineage, and personally identifiable information (PII) handling as risk-reduction with a cost that grows the longer you wait, not as a nice-to-have quality investment competing with the feature. Then pick a first step that piggybacks on work already happening (tagging sensitivity on tables as they get touched during a planned migration, for instance) rather than asking for a dedicated project, so the habit starts without needing a big upfront commitment.
Structured elaboration
Making the case. Governance work is usually deprioritized because its cost is immediate and visible while its payoff is deferred and probabilistic (an incident that might happen). Reframe it concretely: an access-control gap is a specific future incident-response cost (who has access to what, discovered under pressure during an actual incident, is much more expensive than knowing it in advance); missing lineage is a specific future debugging cost (a bad number surfaces and nobody can say quickly where it came from); ungoverned PII is a specific future compliance and trust cost. The pitch is not "governance is good practice," it is "here is the bill we will pay later, and here is the much smaller bill we can pay now instead."
Picking a low-friction first step. The step that works is one that attaches to something already scheduled rather than requesting new headcount or a dedicated sprint: tagging sensitivity classification on tables as part of a migration that is happening anyway, adding an owner field to the catalog entry every time a new dataset gets created (a one-line addition to an existing creation checklist), or capturing lineage automatically as a side effect of adopting a transformation tool the team is already evaluating. The common thread is that it rides on existing momentum instead of asking for new momentum.
What tends to stick versus what does not. A rule enforced by tooling (a required field in a dataset-creation template, a check that blocks a merge if a new table has no declared owner) tends to persist, because it does not depend on anyone remembering. A rule that depends on a person remembering to do an extra step by hand, however well-intentioned at rollout, tends to decay within a quarter once the person who championed it moves to a different priority.
Worked example
A realistic version of this: a team is migrating a set of tables from one warehouse to another anyway. Instead of treating that as a pure lift-and-shift, the migration script is extended to require a sensitivity tag and an owner field before a table is allowed to land in the new warehouse, using values the team already knows (they are moving the table, so they know what it contains and who owns it). No separate governance project gets proposed or approved; the tagging happens as an unavoidable step of work that was already scheduled. Six months later, new tables created after the migration still carry the tag, not because anyone is manually enforcing it, but because the creation template that grew out of the migration script still requires the field. What stuck was the tooling requirement, not a one-time cleanup effort or a policy document asking people to remember.
Trade-offs & pitfalls
The main risk of the "piggyback on existing work" approach is scope creep in the wrong direction: if the governance addition meaningfully slows down the work it is attached to, it becomes the reason the underlying project gets deprioritized instead of quietly succeeding alongside it, so the addition has to be genuinely small. Making the risk-based case too abstract ("this could cause an incident someday") is easy to deprioritize against a concrete deadline; it needs a specific enough scenario to be memorable, without inventing a specific incident that did not happen. And a first step that only touches new work leaves the existing backlog of undocumented, untagged data untouched, so it needs to be paired, eventually, with a plan for the backlog, even if that plan starts smaller and later.
You want to lead a project introducing a schema registry or data-contracts platform at your company. How would you build the business case: what pain point justifies the investment, what would you propose as scope and rollout phases, and what would you actually track over the following year to show it's working rather than just adopted?
Sample Answer
The business case starts from a specific, costed pain point, such as recurring incidents from silent schema breaks, not a generic "we should have better data quality." It proposes a narrow initial scope on the highest-incident datasets with a phased rollout rather than a company-wide mandate, and it commits to tracking outcome metrics, like incidents prevented and breaking changes caught before shipping, rather than adoption metrics alone, since teams can technically adopt a tool while still shipping breaking changes around it.
Naming the pain point
Before proposing a tool, establish the cost of the status quo in terms leadership already tracks: count schema-related incidents over the last two or three quarters from an incident tracker or postmortem log, not memory, and for each one estimate the engineering hours spent on detection and remediation plus any business impact, such as a wrong number in a report or a broken model feature. This turns "we should have contracts" into "schema breaks cost us N incidents and roughly M engineer-hours last quarter, concentrated on these five high-fan-out datasets," which is the sentence that gets budget.
Scope and rollout phases
Do not propose registering every dataset company-wide on day one; that is a multi-year effort with no visible win for months. A realistic phased plan:
- Pilot, one quarter: pick the two or three highest-incident, highest-fan-out datasets identified above, with the producing team as a willing co-sponsor rather than a mandated participant. Prove the CI-compatibility-check flow catches a real breaking change before it ships.
- Expand to the next tier of datasets and make registration the default path for any newly created shared dataset or event.
- Backfill the remaining legacy datasets opportunistically, prioritized by consumer count, not attempted as a big-bang migration.
What to track over the following year, and why adoption alone is the wrong metric
Adoption metrics, such as datasets registered or teams onboarded, are necessary but not sufficient, because a team can register a schema and still ship a breaking change if the CI gate is not actually blocking, or if they route around it under deadline pressure. Track outcome metrics alongside adoption:
- Breaking changes caught by CI before merge, a direct, attributable win.
- Schema-related production incidents, quarter over quarter, expected to trend down on registered datasets specifically.
- Time-to-detect for the schema breaks that do still happen, which should shrink once contracts and lineage make "who is downstream" answerable in minutes rather than days.
- Registration coverage on new datasets specifically, whether registering a new dataset has actually become the default, not just something the original high-priority datasets did.
Worked example
Pulling the last twelve postmortems, six were caused by an unannounced schema or type change on a shared table; each took roughly a day of a senior engineer's time to trace and fix, spread across two engineers on average, which is about a dozen engineer-days a year on preventable incidents, concentrated on the five datasets with the most downstream consumers. The pitch proposes a three-month pilot on those five, measured at the three-month mark by two things: how many would-be-breaking changes the CI gate actually blocked, a leading indicator it is working, and whether the eleventh and twelfth postmortem-worthy break of the year still happens on a registered dataset, which it should not if the pilot is working, versus an unregistered one, which is expected and is the argument for phase two.
Trade-offs and pitfalls
A pilot that is too small to matter, a single low-traffic dataset, proves nothing and will not earn budget for phase two; a pilot that is too big, mandating everyone on day one, burns goodwill before the tool has proven itself. The most common way this initiative dies quietly is measuring only adoption, for example "80% of datasets registered," a year in, without ever checking whether registered datasets actually see fewer incidents; that number can rise while the problem it is supposed to fix keeps happening.
Unlock Full Question Bank
Get access to all Data Governance, Contracts, and Classification interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.