Bird
0
0

You want to test that a combination of user_id and session_id is unique, and also that user_id has no NULLs. How do you combine dbt-utils tests in your schema.yml?

hard📝 Application Q8 of 15
dbt - Advanced Testing
You want to test that a combination of user_id and session_id is unique, and also that user_id has no NULLs. How do you combine dbt-utils tests in your schema.yml?
ACreate a custom SQL test combining both conditions.
BUse only <code>unique_combination_of_columns</code> on both columns; it covers NULL checks automatically.
CUse <code>not_null</code> on both columns and skip uniqueness test.
DAdd two tests under the model: one <code>unique_combination_of_columns</code> with both columns, and one <code>not_null</code> on <code>user_id</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Understand test scopes

    unique_combination_of_columns checks uniqueness but does not check for NULLs explicitly.
  2. Step 2: Combine tests properly

    To ensure no NULLs in user_id, add a separate not_null test on that column.
  3. Final Answer:

    Add two tests under the model: one unique_combination_of_columns with both columns, and one not_null on user_id. -> Option D
  4. Quick Check:

    Combine uniqueness and not_null tests separately [OK]
Quick Trick: Use separate tests for uniqueness and NULL checks [OK]
Common Mistakes:
MISTAKES
  • Assuming uniqueness test checks NULLs
  • Skipping not_null test
  • Trying to combine both in one test incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes