download

Which schema changes break pipelines, and how do you evolve safely?

Data engineering~11 minReviewed 3 Dec 2026Free · No sign-in

Question

Your Kafka-to-Parquet pipeline emits OrderEvent v1 records with three required fields: id (string), cents (long), and reg (string). Downstream analytics jobs read both live messages and 12 months of historical files.

Teams propose four v2 changes:

  1. Add optional nullable coupon (["null", "string"], default: null).
  2. Add required tax (int, no default).
  3. Narrow cents from long to int.
  4. Rename reg to market.

Which changes are backward, forward, or full compatible? How do you enforce compatibility before deploy and handle malformed rows that still arrive?

Show hints (3)
  1. "TEST BOTH READER DIRECTIONS"

    Backward means a new reader reads old v1 data. Forward means an old v1 reader reads new v2 data. Full requires both.

  2. "CHECK DEFAULTS AND WIDENING"

    A new reader needs a default value for any field absent from v1. Avro and Parquet allow widening int to long, never narrowing long to int.

  3. "GATE AND QUARANTINE"

    Block breaking schemas in CI with a schema registry check, and route unparseable runtime rows to a dead-letter path instead of crashing the job.

Show checked explanation

Only adding optional coupon with default: null is full compatible. Adding required tax without a default breaks backward compatibility, narrowing cents from long to int risks overflow on old records, and renaming reg to market breaks both directions. Enforce compatibility in a schema registry CI gate, and quarantine malformed runtime rows to a dead-letter path.

"SOLUTION · PYTHON"
WIDEN = {("int", "long"), ("int", "double"), ("long", "double")}


def is_backward_ok(old, new):
    for col, (typ, has_def) in new.items():
        if col not in old:
            if not has_def:
                return False, f"added {col} without default"
        elif old[col][0] != typ and (old[col][0], typ) not in WIDEN:
            return False, f"bad type {col}: {old[col][0]}->{typ}"
    return True, "compatible"


v1 = {"id": ("str", False), "cents": ("long", False), "reg": ("str", False)}
cases = [("opt", {**v1, "coupon": ("str?", True)}),
         ("req", {**v1, "tax": ("int", False)}),
         ("narrow", {**v1, "cents": ("int", False)}),
         ("rename", {"id": ("str", False), "cents": ("long", False),
                     "market": ("str", False)})]
print("\n".join(f"{k}: {is_backward_ok(v1, s)}" for k, s in cases))
"OUTPUT"
opt: (True, 'compatible')
req: (False, 'added tax without default')
narrow: (False, 'bad type cents: long->int')
rename: (False, 'added market without default')

Author-checked on CPython 3.12.10: ran the backward-compatibility checker, tested forward/full symmetry and int-to-long widening, and tested dead-letter quarantine routing against Apache Avro and Iceberg specifications. Checked by an editor other than the author.

Walkthrough

In a data pipeline, producers, consumers, and 12 months of archived Parquet or Avro files never upgrade at the exact same millisecond. Compatibility rules tell you who can read whose data:

Proposed v2 changeBackward (new reads old)Forward (old reads new)Safe action
Add nullable coupon (default: null)Yes (uses null)Yes (old ignores extra)Full compatible; deploy in any order
Add required tax (no default)No (old rows lack tax)Yes (old ignores tax)Give tax a default or make it nullable
Narrow cents (long to int)No (old values overflow)Yes (int promotes to long)Keep long; only widen types (int to long)
Rename reg to marketNo (market missing)No (reg missing)Add market, dual-write, migrate, drop reg

Pick the right compatibility mode and rollout order:

  • Backward lets new readers process historical v1 files. Upgrade consumers first, then producers.
  • Forward lets old readers ignore new fields. Upgrade producers first, then consumers.
  • Full supports both directions so rolling deploys and historical replays never break. Every added or removed field must carry a default value.

Enforce in CI and quarantine bad runtime rows. Register schemas in a Schema Registry (Avro, Protobuf, or JSON Schema) and fail pull requests on incompatible diffs before producers ship. Even with registry gates, raw JSON webhooks or third-party CSVs still send corrupt payloads. Route unparseable rows to a dead-letter path (storing raw payload, schema version, error message, and timestamp) with an alert, so one bad record never stalls the stream or disappears silently.

Common mistakes

  • Renaming reg to market in place. To Avro and downstream SQL queries, a rename looks like dropping a required field and adding an unknown required one.
  • Setting additionalProperties: false in JSON Schema on an event topic, which breaks forward compatibility whenever a producer adds an optional field.
  • Widening or narrowing types freely without checking historical Parquet files. Reading old long values as int fails or overflows; only safe promotions like int to long work.
  • Dropping unparseable rows silently in a try/except block instead of writing them to a dead-letter path with metrics and alerts.

Follow-up questions

  • "How does Apache Iceberg make renaming a warehouse column safer than raw Parquet?" Iceberg tracks columns by stable numeric field IDs instead of names or positions, so renaming reg to market updates metadata without rewriting old Parquet files. Downstream SQL queries selecting reg still break until you migrate them or expose a view.
  • "How do you safely drop an old optional field under FULL compatibility?" Only drop a field that already had a default value in older schemas. First stop reading it in consumers, wait until old consumers are gone, then remove it from producers while keeping old readers able to fall back to the default.
  • "When should a bad schema record halt the pipeline instead of going to a dead-letter path?" Quarantine isolated malformed rows (for example under 0.1% of volume) so healthy traffic keeps flowing. Trip a circuit breaker and halt publishing if dead-letter share spikes (say above 1%), which signals a broken producer deploy.

What a strong answer covers

Classifies all four changes across backward, forward, and full compatibility, tying each to deploy order and Avro/Parquet type-promotion rules. Pairs schema registry CI gates with a monitored dead-letter quarantine path.

Open in interactive practice deck →

Original OfferVibe question. Apache Avro: Schema Resolution · Apache Iceberg: Schema Evolution · JSON Schema: Object.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.