0
0
dbtdata~10 mins

dbt-expectations for data quality - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a dbt-expectation that checks if the column 'user_id' has no null values.

dbt
expect_column_values_to_not_be_null('[1]')
Drag options to blanks, or click blank then click option'
Aemail
Border_id
Cuser_id
Dcreated_at
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column unrelated to user identification.
Using a column that might have nulls allowed.
2fill in blank
medium

Complete the code to expect that the 'order_amount' column values are greater than zero.

dbt
expect_column_values_to_be_between('[1]', min_value=0, strict_min=True)
Drag options to blanks, or click blank then click option'
Aorder_amount
Bdiscount
Ccustomer_id
Dorder_date
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a date or ID column instead of a numeric amount.
Not setting strict_min=True to exclude zero.
3fill in blank
hard

Fix the error in the dbt-expectation code to check that 'email' column values match a simple email pattern.

dbt
expect_column_values_to_match_regex('[1]', regex=r'^[\w\.-]+@[\w\.-]+\.\w+$')
Drag options to blanks, or click blank then click option'
Aphone_number
Bemail
Cuser_id
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column unrelated to emails.
Not matching the regex to the correct column.
4fill in blank
hard

Fill both blanks to create a dbt-expectation that checks if 'signup_date' values are between '2020-01-01' and '2023-12-31'.

dbt
expect_column_values_to_be_between('[1]', min_value='[2]', max_value='2023-12-31')
Drag options to blanks, or click blank then click option'
Asignup_date
B2020-01-01
Corder_date
D2021-01-01
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name.
Setting an incorrect minimum date.
5fill in blank
hard

Fill all three blanks to create a dictionary that maps each column to an expectation checking values are not null and unique.

dbt
expectations = { '[1]': ['expect_column_values_to_not_be_null', 'expect_column_values_to_be_unique'], '[2]': ['expect_column_values_to_not_be_null', 'expect_column_values_to_be_unique'], '[3]': ['expect_column_values_to_not_be_null', 'expect_column_values_to_be_unique'] }
Drag options to blanks, or click blank then click option'
Auser_id
Bemail
Corder_id
Dsignup_date
Attempts:
3 left
💡 Hint
Common Mistakes
Including date columns which may not be unique.
Missing any of the key identifier columns.