Executing the dbt Model
Lab Steps
Introduction
In this lab step, you will execute the dbt model you previously defined, and will check that the dbt macros have been invoked.
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, two views have been created. The first one is the stg_orders model that was already in the lab environment, the second one is the d_orders model that you just defined (because no materialization type has been defined, it has been materialized as a view).
4. Execute the following command to log into the database:
Copy code
1
psql -U postgres -d ca_dbt
5. Execute the following SQL query to retrieve the first 10 rows of the d_orders view:
Copy code
1
select * from dbt_outputs.d_orders limit 10;
These orders have all been shipped.
6. Execute the following SQL query to retrieve 10 orders that have not been shipped:
Copy code
1
select * from dbt_outputs.d_orders where shipping_status != 'shipped' limit 10;
Summary
In this lab step, you executed the dbt model you previously defined, and checked that the dbt macros have been invoked.
Check whether the dbt models have been executed.