# Avro and Schema Evolution

> Use Avro for row-oriented, schema-first data in streaming and messaging, and learn the rules for evolving schemas without breaking consumers. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/data-engineer/avro-schema-evolution
Last updated: 2026-11-28

Use Avro for row-oriented, schema-first data in streaming and messaging, and learn the rules for evolving schemas without breaking consumers.

Intermediate · about 3 hours · difficulty 3/5

Learn first: [Columnar Formats: Parquet and ORC](https://www.internhack.in/roadmaps/tracks/data-engineer/parquet)

Avro is a compact binary row format with a schema written in JSON. It shines where records are written one at a time and read by many independent consumers, which is why it is popular with Kafka.

### Avro basics

- Every record follows a **schema** (record name, fields, types, defaults).
- Data is binary and compact; the schema travels with the file or is stored in a **schema registry** and referenced by ID.
- Good for write-heavy, row-at-a-time workloads; Parquet is better for analytical scans.

### Schema evolution

Producers and consumers upgrade at different times, so schemas must change safely.

- **Backward compatible**: new readers can read old data (adding a field with a default).
- **Forward compatible**: old readers can read new data (removing an optional field).
- **Full**: both.

Safe changes: add optional fields with defaults. Risky changes: renaming fields, changing types, removing required fields.

### Schema evolution beyond Avro

Parquet and table formats (Delta, Iceberg) also support evolution such as adding columns. Iceberg tracks columns by ID so renames are safe. Protobuf is another schema-first format common in microservices.

### Data contracts

The idea that producers publish an agreed schema and semantics, and changes go through review, grew out of these problems. You will meet it again in the data quality section.

### Pitfalls

- Changing a field from int to string in production and breaking every downstream consumer.
- Adding a required field without a default, making old records unreadable.

You are ready to move on when you can write an Avro schema for a payment event, evolve it by adding a field safely, and explain which change would break backward compatibility.

## Key concepts

- **Avro schemas and types**
- **Binary encoding**
- **Backward and forward compatibility**
- **Schema registry**
- **Protobuf**
- **Avro vs Parquet**

## Mini project

Using the fastavro Python library, write payment events with schema v1, then evolve to v2 by adding an optional upi_app field with a default. Show that a v2 reader can read v1 files and document one change that would break compatibility.

## Check yourself

Why is adding a field with a default backward compatible, while renaming a field is not?

## Free resources

- [Apache Avro documentation](https://avro.apache.org/docs/) (Apache Avro)
- [Confluent documentation (Schema Registry)](https://docs.confluent.io/) (Confluent)
- [Protocol Buffers overview](https://protobuf.dev/overview/) (Google)

Previous: [Columnar Formats: Parquet and ORC](https://www.internhack.in/roadmaps/tracks/data-engineer/parquet) · Next: [Object Storage, Partitioning and Data Lake Layout](https://www.internhack.in/roadmaps/tracks/data-engineer/object-storage-layout)

## More in Storage, File Formats and Data Layout

- [Row-Based Formats: CSV and JSON](https://www.internhack.in/roadmaps/tracks/data-engineer/row-formats)
- [Columnar Formats: Parquet and ORC](https://www.internhack.in/roadmaps/tracks/data-engineer/parquet)
- [Avro and Schema Evolution](https://www.internhack.in/roadmaps/tracks/data-engineer/avro-schema-evolution)
- [Object Storage, Partitioning and Data Lake Layout](https://www.internhack.in/roadmaps/tracks/data-engineer/object-storage-layout)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/data-engineer)
