A data contract is the agreement that says what a dataset will look like and how it will behave, so the people and tools that depend on it are not surprised when the source changes. For an ecommerce brand, that usually means the orders, customers and ad spend tables that feed revenue reports and marketing dashboards. This answer explains what a data contract contains, how dbt enforces one, which changes are safe and which break things, and how to start. It is from Brand Media Works, an AI consulting and marketing data engineering firm for ecommerce brands. Facts are from dbt and Confluent documentation and the Open Data Contract Standard, all read on 15 November 2026.
What is a data contract?
A data contract is an agreement between the people or systems that produce a dataset and the people who use it. Beyond the list of columns, it usually covers quality rules, service levels and how the data is expected to behave, and it is often written as a YAML file.
There is an open standard for the format. The Open Data Contract Standard (ODCS), published by the Linux Foundation project Bitol, "describes the keys and values expected in a YAML data contract". Its sections include data quality, support and communication channels, team, roles and a service-level agreement, and the standard says "The contract should be platform agnostic."
In practice a contract answers four questions for each table: what columns it has and their types, what counts as valid data, who owns it, and how fresh and available it will be.
Why reports break when a source changes
Much of an ecommerce brand's data arrives from systems the data team does not control: the store platform, ad platforms, email tools and apps. When one of them changes a field, every model and dashboard built on it can break or, worse, keep running with wrong numbers.
An invented example. An app that writes order notes into your warehouse changes a discount field from a number to text, so "10" becomes "10%". The revenue model that subtracts discounts now fails, or casts the text to zero and overstates net revenue until someone notices. Confluent's documentation gives the general case: "Sometimes you need to make incompatible changes. For example, modifying a field type from Number to String."
A contract turns that silent change into a loud one. The check fails at the boundary, before the bad data reaches a report.
How dbt enforces a contract
dbt, a tool for building warehouse tables in SQL, has model contracts built in. Its documentation describes a contract as a set of "upfront" guarantees "that define the shape of your model." When the contract is enforced, "dbt will verify that your model's transformation will produce a dataset matching up with its contract, or it will fail to build."
The rules are strict by design. "When enforced, your contract must include every column's name and data_type," and dbt looks for breaking changes against the previous version. Its list of breaking changes includes "Removing an existing column" and "Changing the data_type of an existing column". dbt's advice is that "When the contract changes in a backwards-incompatible way, it is a breaking change that requires a bump in major version."
An invented example of a contract on an orders table, in dbt's YAML format:
models:
- name: fct_orders
config:
contract:
enforced: true
columns:
- name: order_id
data_type: string
constraints:
- type: not_null
- name: order_date
data_type: date
- name: net_revenue
data_type: numeric
- name: discount_amount
data_type: numericTwo limits are worth knowing. Database constraints are only partly enforced: "Most platforms only enforce not_null." And dbt warns against adding contracts too soon: "Introducing governance while models are still changing can complicate future changes."
Contracts and tests do different jobs
"A model's contract defines the shape of the returned dataset," according to dbt. Tests check the values. dbt describes data tests as "a more flexible mechanism for validating the content of your model after it's built." A contract would catch the discount field changing type. A test would catch a discount larger than the order total.
Our recommendation is to use both on the tables that matter most: a contract for the shape, and tests for the rules a finance or marketing lead would check by eye, such as no negative revenue and no order dated in the future.
Which changes are safe
Streaming systems have formal rules for this, and in our view they translate well to warehouse tables. Confluent's Schema Registry documentation defines schema evolution as "the practice of safely changing schemas over time while maintaining compatibility with existing producers and consumers." It describes two directions:
- Backward compatible: "consumers using new schema can read data written with old schema (add optional fields, remove fields)".
- Forward compatible: "consumers using old schema can read data written with new schema (remove optional fields, add fields)".
Confluent notes that "The default compatibility mode is BACKWARD," and that a new field needs a default value to stay compatible: "Had the default value been omitted in the new field, the new schema would not be backward compatible with the old one".
Our rule of thumb for an ecommerce warehouse: adding a new column with a default is safe, renaming or removing a column is breaking, and changing a type is breaking unless every consumer has been checked. Breaking changes ship as a new version of the table, with the old one kept until reports have moved.
How to start
A contract does not need to be complete on day one. Our view is that it is easiest to start with the header and the schema and add rules over time. dbt recommends contracts for "public" models "that are being relied on downstream." These steps are our recommendation for applying that:
- Pick three to five tables. Choose the ones behind revenue, orders, customers and ad spend reporting.
- Write down the schema. Every column name and type, as dbt requires, plus a one-line meaning for each.
- Name an owner and a consumer. A contract usually has one producer and one or more consumers. Write both down so a change has someone to approve it.
- Enforce the shape in dbt. Turn on the contract for those models so a mismatch fails the build.
- Add the rules people care about. Freshness, no nulls in key fields, totals that match the source, as tests.
- Agree how changes happen. Additions announced, breaking changes as a new version with a switchover date.
Contracts fit naturally with the rest of a well-built warehouse. Our answers on medallion architecture and the semantic layer cover where contracted tables sit and how metrics are defined on top of them, and our answer on the marketing data warehouse covers the foundation. Brand Media Works sets up contracts, tests and versioning on a brand's own data as part of its marketing data engineering work.
Frequently asked questions
What is a data contract in simple terms?
A written promise from whoever produces a dataset to whoever uses it: these columns, these types, these quality rules, this owner and this freshness. If the data stops matching, the break is caught before it reaches a report.
What is the difference between a data contract and a schema?
A schema is the list of columns and types. A data contract includes the schema and adds the agreement around it, such as quality rules, ownership and service levels.
What is the difference between a data contract and a data test?
A contract checks the shape of the data, the columns and types, and in dbt it stops the model from building if the shape is wrong. A test checks the values after the model is built, such as no duplicates or no negative revenue.
Who owns a data contract?
The producer of the data owns it and the consumers agree to it. Our view is that in a small brand, that is usually the analyst or engineer who builds the table on one side and the marketing or finance lead who uses the report on the other.
Do I need data contracts if I only use Shopify and a few apps?
Our view is that you need them as soon as a report you make decisions with depends on data from more than one tool. You do not need them on every table. Start with the handful that feed revenue and marketing reporting.