12 minute read
8 February 2024
In today’s landscape, data plays a pivotal role. Success in data initiatives hinges on collaborative teamwork and precise data management. dbt, a leading tool in data operations (data-ops), is at the forefront of instilling robust practices among data-centric teams. Throughout this series, we will delve into the intricacies of a suite of dbt features referred to as dbt Mesh.
Data Mesh is a relatively new concept in the field of data architecture that has gained significant attention in recent times.
Data Mesh is a decentralised approach to data architecture. In this approach, we treat data as a product and the domain or business unit that generates the data are it’s custodians. Data mesh advocates for distributing data ownership and infrastructure responsibilities across different teams or domains within an organisation instead of having it managed by a centralised team.
As you would expect, there are benefits and challenges with this approach.
Possible benefits:
Challenges to be considered:
Even if you’re not heading down a data mesh path, you can still implement these dbt features. Doing so can enhance the trust in your data and improve the manageability of your data transformation pipelines.
dbt, or Data Build Tool, is a configurable tool that simplifies the data transformation processes. With dbt, you can connect to various databases and write SQL or Python code to create datasets (tables, views, etc) that are then materialised in your database. It is simple to use. You can begin in a lightweight manner and then dive deep into richer functionality. It’s for transformations, testing, documentation, orchestration, and applying data governance. (*Note: Some of these capabilities are in the dbtCloud version only)
Git integration, open-source packages hub, and ability to automate make it a favourite among data engineers and analysts.
dbt Mesh takes collaboration and governance to the next level. It introduces simple mechanisms to allow data owners to manage their data assets. These features are:
Implementing DBT mesh has become increasingly popular. Altis is working with a number of organisations across several industries in the ANZ region to help them get started on this journey.
Key lessons so far:
We will start with adding Model Contracts. Following posts will cover:
In dbt, the term Model describes a query that is generally materialised in the database as a view or a table. So, Model Contracts are a set list of columns and their data types in each view or table.
Model Contracts are a quick win to introduce without adding any changes to your current flow of data. Having model contracts gives your downstream data users confidence in the data shape. That is, confidence in what columns will be in their data set and what the datatype of those columns will be.
dbt checks that the contract will be upheld BEFORE actually updating the table or view.
(If you're new to dbt jump to getting started tips)
Step 1: Identify the table or view that is being referenced downstream. This is often in a ‘presentation’, ‘final’ or ‘marts’ folder.

If you have used Exposures in to document your downstream data use, you can also use that to find the models to add contracts to.

For those that prefer using the command line:
dbt list --select 1+resource_type:exposure
models:
- name: dim_supplier
config:
contract:
enforced: true
columns:
- name: supplier_sk
data_type: varchar
- name: supplier_key
data_type: number
- name: supplier_name
data_type: varchar
Simplified yml to show minimum requirement for a contract. Recommendation is for tests and documentation here as well. This file drives a lot of behaviour.
Reach out if you want to talk about any of the configurations available above.
models:
demo_project:
### other model configs and folders here
presentation:
+materialized: table
+contract:
enforced: true
Snippet of dbt_project.yml showing moving the contract enforcement to a folder called presentation
Setting up a brand new dbt project or introducing it to your business is a great time to set solid foundations.
Tips for new projects: enable enforced contracts in your presentation layer from the start. As in step six above, add the contract config to your dbt_project.yml. This will ensure that all presentation models have a contract from the get-go.
If you have a multi-project mesh implementation in mind, set the standard of contracts on all public models too. This will facilitate stability and trust in the shape of the data when you start using the cross-project referencing functionality.
Keep your eyes out for a future how-to on cross-project referencing and how to choose where the barrier between projects should be.
Benefit 1: There is value in finding out first that there is an issue, especially in Prod. Having a contract failure means you are finding out early that there is an issue. You can take steps to resolve and kick off the correct notifications. Users finding out first and needing to log a ticket erodes trust in both the data and the teams involved.
Benefit 2: Save time on identifying the issue and testing.
This is true with issues that pop-up in production or during development.
The error dbt provides are specific. Troubleshooting can start knowing exactly which column there is an issue with.
Fast issue identification means more time resolving the issue and preventing future recurrence. The below errors are telling me:

Benefit 3: In the event that it is a request for change that causes this contract to fail, this will be identified during development (rather than testing). The developer can identify independently that this is a breaking change. The downstream users won’t be asked to test until a solution can be found. Tip: one of the possible solutions here is using Model Versions to allow time for the downstream users to adapt to the change. More on that in a future post.
Meagan is a Senior Managing Consultant with Altis Consulting based in Sydney. She is a dbt Certified Developer and regularly conducts training on dbtCloud.
Connect with Meagan via LinkedIn or get in touch meaganp@altis.com.au
Connect with Altis today to discuss how the dbt features can benefit your organisation.
Other insights

Contact us via the form on our website or connect with us on LinkedIn to explore the best solution for your business.