How and why use exposures?

I’m fairly new in DBT and trying to explore how to exposures. I’ve already read the documentation ( Exposures | docs.getdbt.com ), but I do not feel that I get the answers to my questions.

I’m well aware of the concept that you create an exposures file in your models’ folder, then you declare the table name and the other tables/sources that it depends on.

Q1 - Should I state the whole downstream of tables or just the direct tables that it depends on?

Q2 - What exact benefit does it do? Can you come up with a specific scenario?

Q3 - what the purpose of dbt run -m exposure:name and dbt test -m exposure:name? Is it testing the model or the exposure?

I’ve done exactly what they say in the documentation, I just do not get how I can use it.

Thank you in advance :slight_smile:

Hey @MadsS, good questions! Some answers:

You only need to state the final model(s) in your exposure - it will automatically detect all parents from there to display in the DAG.

A couple of use cases:

  1. If you’re using dbt Cloud, you can generate a metadata tile which shows data freshness and test success in your BI tool. Check out this video from earlier in the year for a demo
  2. We used exposures recently to know which reports would be impacted by a series of source tables being deprecated. We could identify all of them at once and make decisions about whether to upgrade them or replace them. Without exposures, we would have done our best to find them but probably missed one which would have impacted our business users.
  3. It can add confidence in your CI runs to know that proposed changed won’t impact dashboards etc

On their own, running and testing an exposure won’t do anything. However, when you use the + operator, it will run/test the models that feed into an exposure. Here’s our selectors for CI jobs, for example

Thank you very much @joellabes!
I’ll give it all a go! :slight_smile: