Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a test that checks if the column 'id' has no null values.
dbt
select count(*) from [1] where id is null
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() to reference a model.
Using table() which is not a dbt function.
Using model() which is not a dbt function.
✗ Incorrect
In dbt, to refer to a model in SQL, we use the ref() function. So ref('my_model') correctly references the model.
2fill in blank
mediumComplete the code to write a test that checks if the 'email' column contains the '@' character.
dbt
select count(*) from [1] where email not like '%@%'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Using table() which is not a dbt function.
Using model() which is not a dbt function.
✗ Incorrect
To test a model in dbt, use ref() to reference the model named 'users'.
3fill in blank
hardFix the error in the test code that checks for duplicate 'user_id' values.
dbt
select user_id, count(*) from [1] group by user_id having count(*) > 1
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Using table() or model() which are not valid dbt functions.
✗ Incorrect
Use ref() to correctly reference the dbt model 'user_data' in the test query.
4fill in blank
hardFill both blanks to create a test that checks if the 'status' column only contains 'active' or 'inactive'.
dbt
select count(*) from [1] where status not in ([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Using wrong allowed values in the IN clause.
✗ Incorrect
Use ref() to reference the model and specify the allowed values 'active' and 'inactive' in the IN clause.
5fill in blank
hardComplete the code to write a test that checks if the 'order_date' column has any future dates.
dbt
select count(*) from [1] where order_date > current_date
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Adding extra operators after current_date.
✗ Incorrect
Use ref() to reference the model. No extra operator is needed after current_date, so blanks 2 and 3 are empty strings.