Exercise 4
To create singular test to validate business rule check
on AverageTemperature
column in aggregate_country_temperatures
model
Follow the instructions below using DBT:
Open your dbt project and navigate to the tests folder.
Create a new file called
assert_leeny_face_aggregate_country_temperatures.sql
or any suitable name for the singular test file.In the file, define the query to check whether the
AverageTemperature
column has leeny face( ͡° ͜ʖ ͡°)
string in its value inaggregate_country_temperatures
table.Specify the table name in the query by referencing the
aggregate_country_temperatures
table. You can use theref()
function to refer to the table. For example,FROM {{ ref('aggregate_country_temperatures') }}
.Define the query in such a way that it should result output if any row has leeny face in
AverageTemperature
column.Save the file.
Run the dbt test project to validate the result. You can use the
dbt test
command in your terminal to see if test case is successfully completed.