Executing Ephemeral dbt Models
Lab Steps
Introduction
In this lab step, you will execute the dbt models you previously defined and check that the ephemeral model is leveraged by the full-refresh model but not stored in the database.
Instructions
1. Open the terminal by clicking on Terminal -> New Terminal:
2. Move into the dbt project folder by entering the following command:
Copy code
1
cd ca_dbt_project
3. Execute the following command to build the dbt project:
Copy code# The export command is needed to let dbt know the profiles file is in the current directory export DBT_PROFILES_DIR='.' dbt run
After a few seconds, dbt will complete the execution with an output similar to the following:
As you can see, no model named int_more_two_orders has been created. That's because the ephemeral model has been included in models that leveraged it as a CTE and not stored in the database.
4. Execute the following command to log into the database:
Copy code
1
psql -U postgres -d ca_dbt
5. Enter the following command to list out the available tables in the schema that dbt uses for the outputs:
Copy code\dt dbt_outputs.*
As you can see, only the f_orders_avg_discount_yearly full-refresh model has been materialized.
6. Enter the following SQL query to make a query on the f_orders_avg_discount_yearly table:
Copy code
1
select * from dbt_outputs.f_orders_avg_discount_yearly order by year;
Summary
In this lab step, you executed the dbt models you previously defined and checked that the ephemeral model is leveraged by the full-refresh model but not stored in the database.
Check whether the dbt models have been executed.