Skip to main content

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:

  1. Open your dbt project and navigate to the tests folder.

  2. Create a new file called assert_type_check_aggregate_global_emissions_temperatures.sql or any suitable name for the singular test file.

  3. 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
  1. Specify the table name in the query by referencing the aggregate_global_emissions_temperatures table. You can use the ref() function to refer to the table. For example, FROM {{ ref('aggregate_global_emissions_temperatures') }}.

  2. Define the query in such a way that it should result output if any column has different format whicb is specified in the requirement.

  3. Save the file.

  4. 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.