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.
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), 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.
Binary formats manage this in two fundamentally different ways:
- 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.
- 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:
| Field | Version 0: blockLength 25 | Version 1: blockLength 27 |
|---|---|---|
| eventTime | 08 | 08 |
| clearTime | 88 | 88 |
| qtyExponent | 161 | 161 |
| freeQtyDelta | 178 | 178 |
| subscriptionId | 252 | |
| asset | 25length, then its bytes | 27length, 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 findasset, it does not skip 25 bytes, the size of its own block; it skips 27, theblockLengthin the incoming message header. The 2 unfamiliar bytes ofsubscriptionIdare passed over, and the reader lands exactly onassetat offset 27. - A version 0 message reaches a version 1 reader: the new reader sees
version = 0in the header. SincesubscriptionIdwas added in version 1, the reader does not touch offsets25..26(they already hold the start ofasset), reportssubscriptionIdas absent in this version, and skips 25 bytes, theblockLength, to readasset.
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 += 25instead of trustingblockLength = 27, it reads the 2 bytes ofsubscriptionIdas the length ofassetand scrambles the rest of the message. - Changing existing fields in place: widening a field (
uint16touint32), 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
switchdoes 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
subscriptionIdis not sayingsubscriptionId = 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 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, 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.
| 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
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 = 3writes tag0x18(field 3, varint) and its value (0x2afor42). 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 (
0x18is 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). - 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 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
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.