# Schema versioning: evolving binary formats without breaking readers

> How binary schemas change while old and new senders and decoders keep running side by side, what goes wrong when a layout shifts under a reader, and how SBE, Protobuf and Parquet stay compatible across versions.

Page: https://structure.fi/guides/schema-versioning/

An exchange publishes its data to many consumers: trading firms, data vendors, in-house tools, each with a decoder built at a different time. Once the data is out, the exchange can hardly know who reads it, let alone when each reader updates. Now imagine it has to add a new field because a regulation requires it. It cannot stop the world and ask every consumer to wait until they have downloaded the new schema and rebuilt their decoders, so old and new decoders read the same feed side by side.

Recorded data has the same problem from the other end. Years of market data sit in files written under older versions of the schema, and rewriting all of them into the new format is very expensive, so new code has to read old files as they are.

In JSON, adding `"subscriptionId": 42` to an object barely hurts: old code ignores the unknown key, and new code reading an old message notices the key is absent. In a binary format the field names are gone ([how a binary message is put together](https://structure.fi/guides/binary-message/)), and a reader knows what each byte means only from its schema. **Schema versioning** (also called *schema evolution*) is the discipline that keeps old and new schemas able to read each other's bytes without silent corruption.

## The two directions of compatibility

When two versions of a schema are in use at once, messages cross the version boundary both ways:

- **Forward compatibility (newer sender, older reader):** the sender writes data the reader's schema has never heard of. The old reader has to skip those unknown bytes cleanly so it stays in step for the rest of the message.
- **Backward compatibility (older sender, newer reader):** the sender never wrote the new fields. The new reader has to notice that they were not sent, without reading past the sender's bytes into the next section, and without mistaking "not in this version" for a real value or a [null value](https://structure.fi/guides/binary-message/#null-values).

Binary formats manage this in two fundamentally different ways:

1. **Append-only fixed blocks, with the block's length on the wire:** never insert, remove or resize existing fields; only *append* new ones at the end, and put the sender's version and the block's length in every message header so a reader knows where the block really ends.
2. **Tagged or self-describing fields:** give every field a permanent numeric tag on the wire, or embed the whole schema in the file, so a reader skips unknown fields by their tag and finds missing fields simply absent.

## Walking both directions on real bytes

Watch what happens when a balance update with fixed offsets evolves from version 0 to version 1. In version 0 its fixed block is **25 bytes** (`eventTime`, `clearTime`, `qtyExponent`, `freeQtyDelta`), followed by a variable-length `asset` string. Version 1 appends a 2-byte `subscriptionId` at the end of the fixed block, growing it to **27 bytes**. This is exactly how `BalanceUpdateEvent` changed in Binance's Spot API schema:

The block of BalanceUpdateEvent in each schema version: one row per field, each bar as long as its bytes:

| Field | Version 0: blockLength 25 | Version 1: blockLength 27 |
| --- | --- | --- |
| eventTime | offset 0, 8 bytes | offset 0, 8 bytes |
| clearTime | offset 8, 8 bytes | offset 8, 8 bytes |
| qtyExponent | offset 16, 1 byte | offset 16, 1 byte |
| freeQtyDelta | offset 17, 8 bytes | offset 17, 8 bytes |
| subscriptionId |  | offset 25, 2 bytes |
| asset | offset 25, length, then its bytes | offset 27, length, then its bytes |

Now trace both mismatches:

- **A version 1 message reaches a version 0 reader:** the old reader reads the four fields it knows (offsets `0..24`). To find `asset`, it does *not* skip 25 bytes, the size of its own block; it skips **27**, the `blockLength` in the incoming message header. The 2 unfamiliar bytes of `subscriptionId` are passed over, and the reader lands exactly on `asset` at offset 27.
- **A version 0 message reaches a version 1 reader:** the new reader sees `version = 0` in the header. Since `subscriptionId` was added in version 1, the reader does not touch offsets `25..26` (they already hold the start of `asset`), reports `subscriptionId` as absent in this version, and skips 25 bytes, the `blockLength`, to read `asset`.

## What breaks compatibility, and the bugs that bite

Even with a versioned format, four mistakes silently break live feeds:

- **Skipping by your own block size instead of the length on the wire:** if that version 0 reader hard-codes `offset += 25` instead of trusting `blockLength = 27`, it reads the 2 bytes of `subscriptionId` as the length of `asset` and scrambles the rest of the message.
- **Changing existing fields in place:** widening a field (`uint16` to `uint32`), swapping two fields, deleting one in the middle, or reusing a retired field number makes old and new decoders read the same bytes as different things.
- **Unknown enum values:** even when every offset stays aligned, a newer sender can send a new enum value (a new order type or reject reason) that an older reader's `switch` does not expect, so it fails or falls into the wrong default branch.
- **Confusing "not sent in version 0" with "zero" or "null":** an old sender that never knew about `subscriptionId` is not saying `subscriptionId = 0`. Treating a field missing from an older version as zero or null corrupts the logic that uses it.

## How common formats handle it

### SBE (append-only blocks, version and blockLength in the header)

SBE uses append-only blocks. The schema carries a root `version` (`0` at first, raised with each compatible change), and every [message header](https://structure.fi/guides/sbe-message-header/) sends both `version` and `blockLength`. Compatible changes only append: fields at the end of the root block or of a group entry (marked with `sinceVersion`), groups after the existing groups, variable-length data after the existing data, new messages, new enum values. Retired fields are marked `deprecated` and stay on the wire while clients move off them. A message changed any other way needs a new template id, or the whole schema a new `id` with `version` back at `0` ([Binance's schema versions](https://structure.fi/guides/binance-spot-sbe/#schema-versions), [versions and sinceVersion](https://structure.fi/guides/sbe-schema-file/#versions-and-sinceversion)).

In the Market Data Visualizer, open `BalanceUpdateEvent` from the bundled Binance Spot API schema (`id` 3, `version` 6) and set **Display** to version `0` to watch `subscriptionId` (`sinceVersion="1"`) disappear.

Layout of BalanceUpdateEvent in the Binance Spot API SBE schema, as the Market Data Visualizer lays it out:

| Offset | Size | Name | Type | Presence | Since |
| --- | --- | --- | --- | --- | --- |
| 0 | 27 | BalanceUpdateEvent | block |  | 0 |
| 0 | 8 |  eventTime | utcTimestampUs | required | 0 |
| 8 | 8 |  clearTime | utcTimestampUs | optional | 0 |
| 16 | 1 |  qtyExponent | exponent8 | required | 0 |
| 17 | 8 |  freeQtyDelta | mantissa64 | required | 0 |
| 25 | 2 |  subscriptionId | subscriptionId | optional | 1 |
| 27 | 1 |  asset | data varString8 |  | 0 |

[Open BalanceUpdateEvent in the Market Data Visualizer to switch schema versions](https://structure.fi/tools/market-data-visualizer/app/#open?sample=binance-spot&node=m601&place=layout&guide=schema-versioning&section=block-27)

### Protobuf (permanent field numbers, self-delimiting wire types)

Protobuf sends **no schema version on the wire**. Every field present carries a permanent field number and a wire type that tells any reader how many bytes to skip:

- Adding `subscription_id = 3` writes tag `0x18` (field 3, varint) and its value (`0x2a` for `42`). An older reader does not know field 3, skips the varint cleanly (keeping it as an unknown field), and reads on. A newer reader on an older message finds field 3 absent and uses its default (or reports it unset, with explicit presence).
- A reader can skip a field it has never heard of because the tag says how the value is laid out, not only which field it is: its low 3 bits are the **wire type** (`0x18` is field 3 × 8 + wire type 0), and the wire type alone says where the value ends: at a varint's last byte, after 8 or 4 bytes, or after the length written in front of it ([wire types](https://structure.fi/guides/protobuf-wire-format/#wire-types-how-long-a-value-is)).
- Deleting a field means marking its number `reserved`, so nobody reuses that number with a different type. Renaming a field is safe on the wire, because names are never sent.

### Parquet (a schema in every file, merged by the query engine)

Parquet has **no table schema version**: the `version` in a Parquet [footer](https://structure.fi/guides/parquet-file-layout/#the-footer) is the version of the file format, `1` or `2`. Every Parquet file carries its full column schema in its own footer, so reading one file always matches that file's layout.

Evolution happens **across files** of one dataset (older files have 10 columns, newer files add an 11th). Parquet leaves matching those files up to the query engine (DuckDB, Spark, Iceberg, Delta): columns missing from older files read as `NULL`, added columns can be read or ignored, and renaming a column or changing its type needs either careful engine settings or a table format that matches columns by Parquet's numeric `field_id` instead of by name.

[Open the trades sample's schema](https://structure.fi/tools/market-data-visualizer/app/#open?sample=trades&place=symbols&guide=schema-versioning&section=block-34)

## Sources

- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/03MessageStructure.md
- https://github.com/binance/binance-spot-api-docs/blob/master/faqs/sbe_faq.md
- https://protobuf.dev/programming-guides/proto3/#updating
- https://protobuf.dev/programming-guides/editions/#updating
- https://github.com/apache/parquet-format
- https://spark.apache.org/docs/latest/sql-data-sources-parquet.html

Reviewed by Structure on 2026-11-24. Last changed 2026-11-24.
