0
0
dbtdata~10 mins

Model contracts and access controls 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 model contract in dbt.

dbt
version: 2
models:
  - name: my_model
    [1]:
      - name: id
        data_type: integer
Drag options to blanks, or click blank then click option'
Acolumns
Btests
Csources
Dseeds
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tests' instead of 'columns' to define the contract.
Confusing 'sources' with model contract definitions.
2fill in blank
medium

Complete the code to add an access control tag to a model in dbt.

dbt
models:
  - name: sensitive_data
    tags: [[1]]
Drag options to blanks, or click blank then click option'
A"finance"
B"access_control"
C"restricted"
D"public"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'public' tag for sensitive data models.
Using unrelated tags like 'finance' without access meaning.
3fill in blank
hard

Fix the error in the model contract by completing the missing key.

dbt
models:
  - name: user_data
    columns:
      - name: user_id
        [1]: string
Drag options to blanks, or click blank then click option'
Adata_type
Bdatatype
Ctype
Ddtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'type' instead of 'data_type'.
Using 'dtype' which is not recognized by dbt.
4fill in blank
hard

Fill both blanks to create a test for a model contract that checks for uniqueness and non-null values.

dbt
models:
  - name: orders
    columns:
      - name: order_id
        data_type: integer
        tests: [[1], [2]]
Drag options to blanks, or click blank then click option'
Aunique
Bnot_null
Caccepted_values
Drelationships
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'accepted_values' instead of uniqueness test.
Omitting the 'not_null' test.
5fill in blank
hard

Fill all three blanks to define a model contract with columns, data types, and a test for accepted values.

dbt
models:
  - name: products
    columns:
      - name: category
        data_type: string
        tests: [[1]]
      - name: price
        data_type: float
        tests: [[2]]
      - name: stock
        data_type: integer
        tests: [[3]]
Drag options to blanks, or click blank then click option'
Aaccepted_values
Bnot_null
Cunique
Drelationships
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up tests between columns.
Using 'relationships' test where not applicable.