Using Exposures in dbt Core: Define Downstream Uses

Eric Arsenault
3 min readMay 14, 2023

--

Overview of dbt Core and Exposures

dbt Core is an open source command line interface (CLI) that helps users to quickly define, build, and deploy data pipelines. It also supports a feature called Exposures which allows developers to easily categorize their models with minimal effort. With the Exposure feature, users can define downstream uses in YAML files that are nested under an ‘exposures’ key. These files can be named whatever you want (snake_case only) and stored anywhere within the models directory. Exposures can be used to define downstream uses for each model, making them callable at runtime. This makes it easier for developers to make changes to specific model groups when updating existing datasets or creating new ones. Additionally, exposures provide a way to for developers to choose which downstream project they want to refresh at runtime, saving time and resources.

In short, using exposures provides a number of significant advantages. By allowing developers to define, select, and run specific groups of models at runtime, they gain a greater level of modularity over their project.

Understanding Different Types of Exposures

When creating exposures in dbt Core users have the option to choose from a variety of available properties, but only three are required (Name, Type, Owner). All of these properties as a whole can be used to customize the exposure and determine which downstream projects will be affected by it. Some of the other key options include the description, tags, maturity, metadata and even a url to link directly to the downstream use case. By selecting these properties carefully, developers are able to create custom exposures that provide more control over their project’s modularity and flexibility.

Here is a breakdown of the Available Properties:

Available properties

Required:

  • name: a unique exposure name written in snake case
  • type: one of dashboard, notebook, analysis, ml, application (used to organize in docs site)
  • owner: name or email required; additional properties allowed

Expected:

  • depends_on: list of refable nodes, including ref, source, and metric (While possible, it is highly unlikely you will ever need an exposure to depend on a source directly)

Optional:

  • label: may contain spaces, capital letters, or special characters.
  • url: enables the link to View this exposure in the upper right corner of the generated documentation site
  • maturity: one of high, medium, low

General properties (optional)

  • description
  • tags
  • meta

Referencing exposures​

Once an exposure is defined, you can run commands that reference it:

dbt run -s +exposure:finance_dashboards
dbt test -s +exposure:finance_dashboards

Final Thoughts on Utilizing Exposures

Exposures can be a powerful tool for analytics engineers to organize their project and define downstream uses. With exposures, you can create a project that is organized according to different groups of usage, provide labels and URLs so the exposure is easy to find, set maturity ratings on each exposure item, add descriptions, tags and meta data which will help with searching through your codebase more efficiently. All these features make Exposures an invaluable asset when it comes to organizing your project. By taking advantage of this feature within dbt Core, analytics engineers can quickly find what they need while also ensuring that their projects are flexible and modular.

--

--

Eric Arsenault
Eric Arsenault

Written by Eric Arsenault

Tech Lead | Analytics Engineering

No responses yet