Complete the code to define a model contract in dbt.
version: 2 models: - name: my_model [1]: - name: id data_type: integer
The columns key defines the model contract by specifying expected columns and their data types.
Complete the code to add an access control tag to a model in dbt.
models:
- name: sensitive_data
tags: [[1]]The tag "restricted" is commonly used to indicate access control on sensitive models.
Fix the error in the model contract by completing the missing key.
models:
- name: user_data
columns:
- name: user_id
[1]: stringThe correct key to specify the data type in dbt model contracts is data_type.
Fill both blanks to create a test for a model contract that checks for uniqueness and non-null values.
models:
- name: orders
columns:
- name: order_id
data_type: integer
tests: [[1], [2]]The tests unique and not_null ensure the column has unique and non-null values respectively.
Fill all three blanks to define a model contract with columns, data types, and a test for accepted values.
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]]The 'category' column uses accepted_values to restrict allowed categories. The 'price' column uses not_null to ensure prices exist. The 'stock' column uses unique to ensure unique stock entries.