Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is dbt and what does it do?
dbt (data build tool) helps analysts and engineers transform data in their warehouse by writing SQL queries, organizing them, and running them in order.
Click to reveal answer
beginner
How does dbt use SQL in its workflow?
dbt uses SQL files to define transformations. Each SQL file represents a model that creates a table or view in the data warehouse.
Click to reveal answer
intermediate
What role does Jinja play in dbt?
Jinja is a templating language used inside dbt SQL files to add logic like loops, conditions, and variables, making SQL dynamic and reusable.
Click to reveal answer
intermediate
Why does dbt use YAML files?
YAML files in dbt are used to configure models, define tests, document data, and set metadata like descriptions and tags.
Click to reveal answer
advanced
How do SQL, Jinja, and YAML work together in dbt?
SQL defines the data transformations, Jinja adds dynamic logic inside SQL, and YAML configures and documents the models. Together, they make dbt projects organized, flexible, and maintainable.
Click to reveal answer
What does a dbt model usually represent?
AA Python script
BA SQL file that creates a table or view
CA Jinja template only
DA YAML configuration file
✗ Incorrect
In dbt, a model is a SQL file that defines a transformation creating a table or view.
Which language does dbt use to add logic inside SQL files?
APython
BYAML
CJinja
DJavaScript
✗ Incorrect
dbt uses Jinja templating language to add logic like loops and conditions inside SQL.
What is the main purpose of YAML files in dbt?
ATo execute Python code
BTo write SQL queries
CTo run data transformations
DTo configure models and tests
✗ Incorrect
YAML files in dbt configure models, define tests, and add documentation.
How does dbt run your data transformations?
ABy running SQL queries defined in models
BBy compiling YAML files
CBy executing Python scripts
DBy using JavaScript functions
✗ Incorrect
dbt runs the SQL queries you write in models to transform data in your warehouse.
Which of these is NOT a function of Jinja in dbt?
ADefining model metadata
BAdding loops and conditions in SQL
CUsing variables inside SQL
DMaking SQL reusable
✗ Incorrect
Defining model metadata is done in YAML, not Jinja.
Explain how SQL, Jinja, and YAML work together in a dbt project.
Think about how each language contributes to building and managing data models.
You got /3 concepts.
Describe the role of Jinja templating in making SQL dynamic within dbt.
Consider how you might write one SQL file that can change based on inputs.
You got /3 concepts.
Practice
(1/5)
1. What is the main role of Jinja in dbt projects?
easy
A. To add logic and dynamic behavior to SQL queries
B. To write raw SQL queries without any modification
C. To manage configuration and documentation files
D. To execute the SQL queries on the database
Solution
Step 1: Understand Jinja's purpose in dbt
Jinja is a templating language that allows adding logic like loops and conditions inside SQL files.
Step 2: Differentiate roles of SQL, Jinja, and YAML
SQL writes queries, YAML manages configs/docs, and Jinja adds dynamic logic to SQL.
Final Answer:
To add logic and dynamic behavior to SQL queries -> Option A
A. Because the indentation for 'users' is incorrect under 'my_project'
B. Because '+materialized' cannot be set in YAML
C. Because tags must be a string, not a list
D. Because 'models' key is missing
Solution
Step 1: Check YAML indentation rules for dbt configs
In dbt, model configs under a project must be indented properly; 'users' should be at the same level as '+materialized'.
Step 2: Identify the indentation error
'users' is indented too far, making it a child of '+materialized' which is invalid.
Final Answer:
Because the indentation for 'users' is incorrect under 'my_project' -> Option A
Quick Check:
YAML indentation matters for nested configs [OK]
Hint: Check YAML indentation carefully for nested configs [OK]
Common Mistakes:
Ignoring YAML indentation importance
Thinking '+materialized' is invalid syntax
Assuming tags cannot be lists
5. You want to create a dbt model that selects only active users from a table, but the 'active' flag is stored in a YAML config. Which approach correctly combines SQL, Jinja, and YAML to achieve this?
hard
A. Use Jinja to read YAML directly inside SQL without defining variables
B. Write WHERE active = true directly in SQL without YAML or Jinja
C. Define 'active_flag: true' in YAML, then use WHERE active = {{ var('active_flag') }} in SQL with Jinja
D. Set 'active_flag' in YAML but forget to use Jinja in SQL, so filter is missing
Solution
Step 1: Store the filter value in YAML as a variable
Define 'active_flag: true' in YAML under vars or config to make it accessible.
Step 2: Use Jinja to insert the variable in SQL WHERE clause
Use WHERE active = {{ var('active_flag') }} so the SQL filters active users dynamically.
Final Answer:
Define 'active_flag: true' in YAML, then use WHERE active = {{ var('active_flag') }} in SQL with Jinja -> Option C
Quick Check:
YAML vars + Jinja in SQL = dynamic filters [OK]
Hint: Use YAML vars + Jinja {{ var() }} in SQL WHERE [OK]