Exercise 3
To create singular test to validate type check
on all column in aggregate_global_emissions_temperatures
model
Follow the instructions below using DBT:
Open your dbt project and navigate to the tests folder.
Create a new file called
assert_type_check_aggregate_global_emissions_temperatures.sql
or any suitable name for the singular test file.In the file, define the query to check whether all the columns are in below specified type in
aggregate_global_emissions_temperatures
table.
YEAR: INTEGER
TOTALEMISSIONS: DOUBLE
LANDAVERAGETEMPERATURE: DOUBLE
LANDMAXTEMPERATURE: DOUBLE
LANDMINTEMPERATURE: DOUBLE
LANDANDOCEANAVERAGETEMPERATURE: DOUBLE
Specify the table name in the query by referencing the
aggregate_global_emissions_temperatures
table. You can use theref()
function to refer to the table. For example,FROM {{ ref('aggregate_global_emissions_temperatures') }}
.Define the query in such a way that it should result output if any column has different format whicb is specified in the requirement.
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.