Entitx

Lineage and integration

Data contracts between producers and consumers: what to agree and how

  • Updated
  • 8 min read
Contents

Most data incidents are not bugs. Someone upstream changed something that someone downstream relied on: a column renamed, a new code value, a file delivered two hours later than usual. A data contract makes these dependencies explicit. The producer of a data set agrees with its consumers what they will receive, in what shape, of what quality, how often, and how changes will be handled.

In short

  • A data contract is an agreement between the producer of a data set and its consumers about what the data is and what they can rely on.
  • It covers the schema, the meaning of each field, quality expectations, service levels such as freshness and availability, access and use, and the rules for change.
  • The producer owns the contract; consumers are known by name and purpose.
  • Contracts work best when they are machine-readable and checked automatically before data is published.
  • A breaking change needs notice, a new version and a period in which both versions run.

Why data contracts

Data moves between teams through interfaces: files, APIs, event streams, shared tables. Each producing team looks after its own system, and the consumers of its data depend on it silently. Without an explicit agreement:

  • a change that is harmless for the producer breaks reports, models and processes downstream;
  • nobody has said how fresh or how complete the data should be, so every delay becomes a dispute;
  • quality problems are found by consumers, far from the place where they could be fixed;
  • the producer does not know who uses the data, so nobody can be warned.

A data contract moves responsibility to where the data is created: the team that produces a data set answers for it, as a team that offers an API answers for its API. The idea is not new: interface specifications, service level agreements and API contracts have existed for a long time. Data contracts apply it to data sets, and they are a building block of data products in data mesh.

What a data contract contains

SectionWhat it saysExample
PartiesThe producer (its system and owning team), the consumers and the purpose of eachThe order system’s team; finance reporting and demand planning
DescriptionWhat the data set represents, and at what granularityOne row per order line, from order entry onwards
SchemaFields, data types, keys, required fields, allowed valuescurrency_code CHAR(3), values from ISO 4217
MeaningThe business definition of each field, with units and time zonesAmounts in the order currency, excluding tax; times in UTC
QualityThe rules and thresholds the producer checks before publishingNo duplicate order lines; under 0.1% unknown products
Service levelsFreshness, frequency, availability, volume, retentionComplete by 06:00 on business days; kept for 7 days
DeliveryHow the data travels and where it is foundA daily file, an event topic, a table in the warehouse
Access and useClassification, personal data, permitted usesContains personal data; use limited to the stated purposes
Change rulesVersioning, what counts as breaking, notice and deprecation30 days’ notice before a breaking change; both versions run for 60 days
SupportContacts, the incident process, response timesThe data steward and the team’s support channel
StatusWhere the contract is in its life cycleDraft, active, deprecated, retired

The meaning of the fields matters as much as their types. Link each field to its term in the business glossary, so that “net amount” means the same in the contract as in every report built on it.

Breaking and non-breaking changes

ChangeUsuallyWhy
Adding an optional fieldNot breakingExisting consumers ignore what they do not read
Adding a value to a code listBreaking for someConsumers with fixed mappings reject or misclassify the new value
Removing or renaming a fieldBreakingQueries and loads fail
Changing a data type or lengthBreakingLoads fail, or values are truncated
Making a required field optionalBreakingConsumers count on a value being there
Changing the meaning, unit or calculationBreaking, and silentNothing fails, but every result changes
Delivering later or less oftenBreaking for time-critical consumersJobs downstream run on incomplete data

The most dangerous changes are the semantic ones: the schema stays the same, so no technical check fails. Only a contract that states the meaning of each field, and a habit of announcing changes to it, protects against them. For event streams, schema registries can enforce compatibility, accepting only new schema versions that remain readable for existing consumers.

Who does what

ProducerConsumer
Owns the contract and keeps the data within itRegisters as a consumer and states the purpose
Checks the schema and the quality rules before publishingUses the data as described, not undocumented behaviour
Announces changes with the agreed notice, and versions themTests against a new version within the notice period
Reports incidents and fixes them at the sourceReports problems through the agreed channel

Consumers do not write the contract for the producer. They can ask for guarantees, but only the producer can commit to them.

Introducing data contracts

  1. Start where it hurts. Begin with the interfaces behind critical reports and regulatory outputs, and those with many consumers.
  2. Write the contract where the producer works. A machine-readable file, in YAML or JSON, kept in version control next to the code that produces the data. Open standards have appeared for this, such as the Open Data Contract Standard (ODCS), maintained by the Bitol project of the Linux Foundation AI & Data.
  3. Check it automatically. Validate the schema and the quality rules in the producer’s pipeline before the data is published, and stop or quarantine a delivery that breaks the contract.
  4. Register it in the catalog. Connect the contract to the data lineage, the glossary and the list of consumers, so that it can be found and its impact assessed.
  5. Agree a change process: a proposal, an impact analysis through the lineage, notice to the consumers, a new version, a parallel run and the retirement of the old version.
  6. Review regularly. Retire contracts nobody uses any more, and keep the list of consumers current.

Data contracts and other agreements

AgreementBetweenCovers
Data contractThe producer and the consumers of a data setSchema, meaning, quality, service levels, change rules
API specificationAn API provider and its clientsEndpoints, messages and errors, written for example in OpenAPI or AsyncAPI
Service level agreementA service provider and its customersAvailability, support and response times
Data sharing agreementTwo organizationsLegal terms: purpose, permitted use, protection, liability
Data processing agreementA controller and a processor under the GDPR (Article 28)Processing personal data on behalf of the controller

They complement each other. An interface with an outside party may need a data sharing agreement for the legal terms and a data contract for what is delivered and how.

Common mistakes

  • Contracts that nobody checks. A document no pipeline validates becomes outdated with the first change.
  • Schema without meaning. Field names and types say nothing about units, scope or calculation.
  • Unknown consumers. A producer cannot give notice to teams it does not know about.
  • Contracts written by consumers. Guarantees the producer never agreed to are wishes.
  • No change process. Without notice and versions, a contract only describes the data until the next release.
  • Everything at once. Contracts for hundreds of data sets at once become paperwork; start with the critical ones.
  • Forgetting outside parties. Data received from or sent to other organizations needs contracts most.

Frequently asked questions

What is a data contract?

A data contract is an agreement between the producer of a data set and its consumers about what the data contains and what consumers can rely on: the schema, the meaning of each field, quality expectations, service levels such as freshness, permitted use, and how changes will be announced and versioned.

What should a data contract include?

The producer and consumers, a description of the data and its granularity, the schema, the business meaning of each field, quality rules and thresholds, service levels such as freshness, frequency and availability, delivery details, access and permitted use, change rules with a notice period, support contacts and the status of the contract.

Who owns a data contract?

The producer. The team that creates the data commits to what it delivers and keeps the data within the contract. Consumers register their use and purpose, and can ask for changes, but only the producer can make the commitments a contract contains.

What is the difference between a data contract and an SLA?

A service level agreement covers the availability and support of a service. A data contract covers the data itself: its structure, meaning and quality, as well as service levels such as freshness. A data contract often includes service levels, but an SLA alone says nothing about what the data means.

How do you handle breaking changes in a data contract?

Announce them with the notice period the contract promises, publish the change as a new version, run the old and the new version side by side long enough for every consumer to move, and retire the old version only after that. Use the lineage to find every consumer the change reaches.

Do we need a special tool for data contracts?

Not to start. A contract can begin as a structured file in version control, checked by tests in the producer’s pipeline. Tools help when there are many contracts: to validate them automatically, to register them in the data catalog and to connect them to lineage and impact analysis.