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:
Open your dbt project and navigate to the tests folder.
Create a new file called
assert_unique_check_europe_big_three_emissions.sql
or any suitable name for the singular test file.In the file, define the query to check whether the
Year
column is unique ineurope_big_three_emissions
view.Specify the view name in the query by referencing the
europe_big_three_emissions
view. You can use theref()
function to refer to the view. For example,FROM {{ ref('europe_big_three_emissions') }}
.Define the query in such a way that it should result output if
year
column has duplicates.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.