A model contract in dbt is a formal agreement that defines the expected schema and data quality for a model. It ensures that the model meets certain standards before being used by other models or reports.
Click to reveal answer
beginner
Why are access controls important in dbt projects?
Access controls help manage who can view or modify dbt models and data. They protect sensitive data and maintain the integrity of the data pipeline by limiting permissions to authorized users only.
Click to reveal answer
intermediate
How does dbt enforce model contracts?
dbt enforces model contracts by using schema tests and constraints that check if the data matches the defined contract. If the data does not meet the contract, dbt will raise errors during runs.
Click to reveal answer
intermediate
What are some common access control methods used with dbt?
Common access control methods include role-based access control (RBAC), permissions on the data warehouse, and limiting access to dbt project files through version control systems.
Click to reveal answer
beginner
How can model contracts improve collaboration in data teams?
Model contracts provide clear expectations for data quality and schema, which helps team members trust the data and reduces misunderstandings. This leads to smoother collaboration and faster development.
Click to reveal answer
What does a model contract primarily define in dbt?
AExpected schema and data quality
BUser access permissions
CData warehouse location
DVersion control settings
✗ Incorrect
A model contract defines the expected schema and data quality for a model.
Which of the following is NOT a way to enforce access controls in dbt?
AUsing schema tests
BLimiting data warehouse permissions
CRole-based access control
DRestricting project file access
✗ Incorrect
Schema tests enforce data quality, not access controls.
What happens if data does not meet the model contract in dbt?
AModel contract is ignored
BData is automatically corrected
Cdbt raises an error during runs
DAccess is revoked
✗ Incorrect
dbt raises errors if data does not meet the model contract.
Why are model contracts helpful for data teams?
AThey control user access
BThey improve data trust and collaboration
CThey replace version control
DThey speed up data warehouse queries
✗ Incorrect
Model contracts improve trust and collaboration by setting clear data expectations.
Which tool is commonly used to manage dbt project file access?
AData warehouse permissions
BData contracts
CSchema tests
DVersion control systems
✗ Incorrect
Version control systems manage access to dbt project files.
Explain what a model contract is in dbt and how it helps maintain data quality.
Think about how dbt ensures models meet standards before use.
You got /4 concepts.
Describe different ways to implement access controls in a dbt project and why they are important.
Consider who can see or change data and project files.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a model contract in dbt?
easy
A. To schedule when models run in dbt Cloud
B. To define rules that ensure data quality in models
C. To control who can access the dbt project files
D. To create visual dashboards from model data
Solution
Step 1: Understand what a model contract does
A model contract sets rules that data must follow to be considered valid in dbt models.
Step 2: Compare options to the definition
Only To define rules that ensure data quality in models describes defining rules for data quality, which matches the purpose of model contracts.
Final Answer:
To define rules that ensure data quality in models -> Option B
Quick Check:
Model contract = data quality rules [OK]
Hint: Model contracts = rules for data quality [OK]
Common Mistakes:
Confusing access control with model contracts
Thinking contracts schedule runs
Mixing contracts with visualization tools
2. Which of the following is the correct syntax to define a model contract in a dbt model's schema.yml file?
easy
A. models:
- name: my_model
access_control:
users:
- admin
C. models:
- name: my_model
contract:
columns:
- name: id
tests:
- not_null
D. models:
- name: my_model
dashboard:
enabled: true
Solution
Step 1: Identify the syntax for model contracts in schema.yml
Model contracts are defined under the contract key with column tests inside schema.yml.
Step 2: Match options to this syntax
models:
- name: my_model
contract:
columns:
- name: id
tests:
- not_null correctly shows contract with columns and tests. Others show unrelated keys like access_control, schedule, or dashboard.
Final Answer:
models:
- name: my_model
contract:
columns:
- name: id
tests:
- not_null -> Option C
But analysts report they cannot see the customers model. What is the likely error?
medium
A. The access_control block is not supported in dbt_project.yml
B. The role name 'analyst' is misspelled
C. The models list must be under each model, not role
D. The customers model does not exist in the project
Solution
Step 1: Check where access controls are defined in dbt
dbt does not support an access_control block in dbt_project.yml. Access controls are managed outside or via external tools.
Step 2: Analyze other options
Role spelling or model existence might cause issues, but the main problem is unsupported syntax in the config file.
Final Answer:
The access_control block is not supported in dbt_project.yml -> Option A
Quick Check:
Access control block unsupported = The access_control block is not supported in dbt_project.yml [OK]
Hint: Access controls not set in dbt_project.yml [OK]
Common Mistakes:
Trying to set access control inside dbt_project.yml
Assuming role names cause access issues
Not verifying model existence
5. You want to enforce that only users with the 'data_engineer' role can modify the finance model, and that the model must always have a non-null transaction_id. How can you combine model contracts and access controls to achieve this?
hard
A. Define a model contract in schema.yml for transaction_id not null, and manage access control via your data platform's permissions for 'data_engineer' role
B. Add an access control block in schema.yml restricting 'finance' model to 'data_engineer', and add a contract test for transaction_id
C. Use a dbt macro to check user role inside the model SQL and raise error if not 'data_engineer', plus contract test for transaction_id
D. Set transaction_id as primary key in the database and assign 'data_engineer' role ownership on the model
Solution
Step 1: Use model contracts for data quality
Define a contract test in schema.yml to ensure transaction_id is not null, enforcing data quality.
Step 2: Manage access control outside dbt
dbt does not handle user permissions directly; access control is managed by your data platform or warehouse permissions for the 'data_engineer' role.
Final Answer:
Define a model contract in schema.yml for transaction_id not null, and manage access control via your data platform's permissions for 'data_engineer' role -> Option A
Quick Check:
Contracts for data rules + external access control = Define a model contract in schema.yml for transaction_id not null, and manage access control via your data platform's permissions for 'data_engineer' role [OK]
Hint: Use contracts for data, platform for access control [OK]
Common Mistakes:
Trying to set access control inside dbt schema.yml
Using macros to check user roles inside SQL
Assuming dbt manages user permissions directly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.