0
0
dbtdata~10 mins

Why testing ensures data quality in dbt - Test Your Understanding

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

Complete the code to define a basic test that checks if a column has no null values.

dbt
version: 2
models:
  - name: customers
    columns:
      - name: email
        tests:
          - [1]
Drag options to blanks, or click blank then click option'
Anot_null
Brelationships
Caccepted_values
Dunique
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'unique' which checks for duplicates, not nulls.
Using 'accepted_values' which checks for allowed values, not nulls.
2fill in blank
medium

Complete the code to add a test that checks if values in the 'status' column are within allowed values.

dbt
version: 2
models:
  - name: orders
    columns:
      - name: status
        tests:
          - accepted_values:
              values: [1]
Drag options to blanks, or click blank then click option'
A['yes', 'no']
B['open', 'closed']
C['active', 'inactive']
D['pending', 'shipped', 'delivered']
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing values unrelated to order status.
Using an empty list or wrong format.
3fill in blank
hard

Fix the error in the test definition that checks for unique values in the 'user_id' column.

dbt
version: 2
models:
  - name: sessions
    columns:
      - name: user_id
        tests:
          - [1]
Drag options to blanks, or click blank then click option'
Anot_null
Bunique
Caccepted_values
Drelationships
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not_null' which only checks for missing values.
Using 'relationships' which checks foreign key constraints.
4fill in blank
hard

Fill both blanks to create a test that checks if 'order_id' in 'orders' model exists in 'order_details' model.

dbt
version: 2
models:
  - name: orders
    columns:
      - name: order_id
        tests:
          - [1]:
              to: [2]
Drag options to blanks, or click blank then click option'
Arelationships
Borders.order_id
Cref('order_details.order_id')
Dunique
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'unique' instead of 'relationships'.
Referencing the wrong table or column in 'to'.
5fill in blank
hard

Fill all three blanks to define a custom test that checks if the 'age' column values are greater than 18.

dbt
version: 2
models:
  - name: users
    tests:
      - name: age_check
        test: "select * from [1] where [2] [3] 18"
Drag options to blanks, or click blank then click option'
Aref('users')
Bage
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong table name.
Using '>' instead of '<=' for the condition.
Referencing the wrong column.