Back
January 2, 2024

What's the Point of DBT?

John Wesel
11 Jan 2022
5 min read
DBT (Data Build Tool), the “T” in E.L.T., provides powerful functionalities to enhance the efficiency and effectiveness of data teams. Here, we explore four fundamental features of DBT: Shared Data Definitions, Version Control, Multi-Environment Support & Testing, and Efficiency in Company Investment.

Shared Data Definitions

The shared data definition feature of DBT ensures that work is done only once. Instead of repeating tasks, teams can create standard definitions that are universally applicable. A good example of this is the common definition of metrics like margin. This feature enables teams to have a unified approach to important metrics, reducing ambiguity and discrepancy.

Consider a scenario where you need to calculate the profit margin frequently. Using DBT, you can define a metric ‘margin’ as below:

calculate_margin(revenue, cost) = (revenue - cost) / revenue)

Further, DBT provides a central location to update definitions. This centralized updating system cascades changes to all reports, ensuring consistency and accuracy.

Version Control

DBT’s version control provides a clear history of what a report was, the changes made, and who made them. This feature promotes accountability and makes tracking alterations seamless. If an error occurs or a rollback is required, DBT’s version control makes it easy to revert to a previous state.

For instance, each version of a dbt model or macro is stored in the git repository. This allows you to track changes over time and rollback to a previous version if necessary:

git log -- dbt_project/models/my_model.sql

Multi-Environment Support & Testing

DBT elevates the service level to businesses by treating bugs in the data as urgently as in other software. By defining clear boundaries between production-ready and non-production components, teams can easily distinguish reliable data. DBT’s ability to write tests prevents bugs from infiltrating production, ensuring the integrity of the data.

An example of dbt testing includes checking for unique or not null values:

version: 2
models:
 - name: my_model
   tests:
     - unique:
         column_name: id
     - not_null:
         column_name: id

This helps ensure that the ‘id’ column of ‘my_model’ is unique and not null.

Efficiency in Company Investment

DBT is designed to protect a company’s investment by minimizing maintenance costs. By reducing the time analysts spend on moving data and increasing their analysis time, DBT boosts productivity and efficiency.

For instance, dbt’s ref function allows analysts to build on top of existing models without manually handling the underlying data:

select * from ref('my_model')

By using the ref function, analysts can focus more on analysis, rather than moving data.

In conclusion, DBT provides an efficient, robust, and adaptable framework for data transformation. It offers features that streamline work processes, enhance accountability, improve testing, and boost overall efficiency, making it an invaluable tool for any data team.