0
0
dbtdata~10 mins

Generic tests with parameters in dbt - Interactive Code Practice

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

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

dbt
version: 2
models:
  - name: users
    columns:
      - name: email
        tests:
          - not_null:
              [1]: true
Drag options to blanks, or click blank then click option'
Aseverity
Bconfig
Cparams
Denabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'params' instead of 'enabled' to activate the test.
Confusing 'severity' with enabling the test.
2fill in blank
medium

Complete the code to pass a parameter to a generic test that checks if values are greater than a threshold.

dbt
tests:
  - dbt_utils.expression_is_true:
      expression: "{{ column_name }} > {{ params.[1] }}"
Drag options to blanks, or click blank then click option'
Athreshold
Bvalue
Climit
Dmin_value
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' which is too generic.
Using 'limit' which is less common in dbt tests.
3fill in blank
hard

Fix the error in the generic test definition by completing the missing parameter name.

dbt
tests:
  - dbt_utils.unique_combination_of_columns:
      combination_of_columns: ["user_id", [1]]
Drag options to blanks, or click blank then click option'
Aemail
B"email"
C'email'
Demail_column
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around column names.
Using variable names instead of string literals.
4fill in blank
hard

Fill both blanks to create a generic test that checks if a column's values are within a list of allowed values.

dbt
tests:
  - dbt_utils.accepted_values:
      column_name: [1]
      values: [2]
Drag options to blanks, or click blank then click option'
A"status"
B["active", "inactive", "pending"]
C"state"
D["open", "closed"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes for column_name.
Not using a list for values.
5fill in blank
hard

Fill all three blanks to define a generic test with parameters for a column, a threshold, and a severity level.

dbt
tests:
  - dbt_utils.expression_is_true:
      expression: "{{ [1] }} > {{ params.[2] }}"
      severity: [3]
Drag options to blanks, or click blank then click option'
Acolumn_name
Bthreshold
C"ERROR"
D"WARNING"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names.
Not quoting the severity level.