In this lesson we will learn about the DBT ethemeral views feature.
This lab is also available as a video:
DBT executes it's transformations as a series of chained operations represented by a Directed Acyclic Graph (DAG).
For each of the intermediate and final steps of this chain of operations, we can choose how to materialise the results. Typically people will choose between tables and views.
As DBT executes the operations, each of the tables and views will be generated in the database. If they are tables, they of course would require storage. If they are views, the object will simply be created in the database on top of the underlying data.
There are many cases where we would prefer our data consumers do not use these intermediate objects. Perhaps they are likely to change, or contain data in a structure which is in some way not ready or appropriate for consumption.
Ethemeral views can be useful in this situation, as they are not actually created in the database.
The Ethemeral view allows us to represent some intermediate concept in our transformation logic, but it is never actually created in the database. Instead, DBT will interpolate the query so that it is used.
Let's create a new view, marking the type as ethemeral:
If we execute a DBT run at this stage, we can confirm that no object named favourite_pizza_toppings has been created:
In this lesson we explored the concept of Ethemeral views, which allow us to represent some intermediate transformation step as part of the DBT code, without actually creating any data object.
The benefits of this include cleaner and more maintainable transformation code and database.