Skip to main content

Exercise 7

To create singular test to validate uniqueness check on Year column in europe_big_three_emissions 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_unique_check_europe_big_three_emissions.sql or any suitable name for the singular test file.

  3. In the file, define the query to check whether the Year column is unique in europe_big_three_emissions view.

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

  5. Define the query in such a way that it should result output if year column has duplicates.

  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.