This example shows a sales model with tests to ensure sale_id is unique and not null, sale_amount is not null, and sale_status only contains allowed values.
But when you run dbt test, you get an error saying Invalid test configuration. What is the likely cause?
medium
A. The test name should be unique and not_null without dashes
B. The indentation of the tests list is incorrect
C. The model name should be under models key in schema.yml
D. The email column does not exist in the model
Solution
Step 1: Check the structure of schema.yml
Tests must be defined under the models: key in schema.yml.
Step 2: Identify missing models: key
The snippet misses the models: root key, causing invalid configuration.
Final Answer:
The model name should be under models key in schema.yml -> Option C
Quick Check:
Missing 'models:' key = config error [OK]
Hint: Always start schema.yml tests under 'models:' key [OK]
Common Mistakes:
Removing dashes from test names
Incorrect indentation of tests list
Not placing model under 'models:'
5. You want to test that the status column in your transactions model only contains the values 'pending', 'completed', or 'failed'. Which test definition in schema.yml correctly enforces this?
hard
A. - name: transactions
columns:
- name: status
tests:
- values_in: ['pending', 'completed', 'failed']
B. - name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed']
C. - name: transactions
columns:
- name: status
tests:
- accepted_values: ['pending', 'completed', 'failed']
D. - name: transactions
columns:
- name: status
tests:
- unique
- not_null
Solution
Step 1: Identify the correct test for allowed values
The accepted_values test checks if column values are in a list.
Step 2: Check correct syntax for accepted_values
The test requires a dictionary with key values listing allowed values.
Final Answer:
- name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed'] -> Option B
Quick Check:
accepted_values with 'values' key = - name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed'] [OK]
Hint: Use accepted_values with 'values' list for allowed values [OK]
Common Mistakes:
Using unique or not_null instead of accepted_values
Omitting 'values:' key under accepted_values
Using wrong test name like values_in
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.