Skip to main content

Exercise 5

To create singular test to validate consistency check on Country column in aggregate_country_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_initcap_aggregate_country_emissions_temperatures.sql or any suitable name for the singular test file.

  3. In the file, define the query to check whether the country column is in InitCap format in aggregate_country_emissions_temperatures table.

  4. Specify the table name in the query by referencing the aggregate_country_emissions_temperatures table. You can use the ref() function to refer to the table. For example, FROM {{ ref('aggregate_country_emissions_temperatures') }}.

  5. Define the query in such a way that it should result output if any row has country column other than InitCap format.

  6. Save the file.

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