Writer and Reader Schema

The writer schema describes how a record was encoded. The reader schema describes the structure a consumer wants to read. Avro resolves the two rather than assuming the consumerโ€™s newest schema is the schema that produced every stored record.

Suppose an old writer has no coupon_code field and a new reader adds a nullable string with a null default. The reader can fill that default when reading the old record. If the writer schema declares the field but the encoded payload is malformed, reader defaults do not repair it. A default also does not grant permission to omit a field while writing; null must be allowed by the fieldโ€™s type.

A reader may ignore writer fields it does not request. Some numeric promotions are allowed, including long to double, but structural compatibility does not preserve every integer exactly in floating point. Names, aliases, unions, and other schema features have format-specific rules; the simplified lab does not implement all Avro resolution.

Keep writer-schema identity with the encoded data and retain its definition. Test the reader against the writer versions that remain in storage or deployment. Even successful resolution cannot detect a change from dollars to cents under the same numeric type; business units and meaning remain part of the contract.

Try the examples in Designing Topics and Event Contracts.

Further reading


Discover more from Insightful Data Lab

Subscribe to get the latest posts sent to your email.

Similar Posts

Questions, corrections, or additional insights?

This site uses Akismet to reduce spam. Learn how your comment data is processed.