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 a doc block in dbt?
A doc block in dbt is a reusable piece of documentation that you write once and can reference in multiple places to keep descriptions consistent and easy to maintain.
Click to reveal answer
beginner
How do you define a doc block in dbt?
You define a doc block in a .yml file under the 'docs:' key, giving it a name and a description. For example:
docs: customer_description: description: 'Details about the customer table and its purpose.'
Click to reveal answer
beginner
How can you use a doc block in a model or column description?
You use the 'doc' function with the doc block's name inside double curly braces. For example, in a column description:
description: '{{ doc("customer_description") }}'
This inserts the reusable description.
Click to reveal answer
beginner
Why are doc blocks helpful in dbt projects?
Doc blocks help keep documentation consistent, reduce repetition, and make it easier to update descriptions in one place instead of many, improving project maintainability.
Click to reveal answer
intermediate
Can doc blocks include markdown formatting?
Yes, doc blocks support markdown formatting, so you can add lists, links, and emphasis to make your documentation clearer and more readable.
Click to reveal answer
Where do you define doc blocks in a dbt project?
AIn the profiles.yml file
BInside SQL model files
CIn the dbt_project.yml file
DIn the .yml files under the 'docs:' key
✗ Incorrect
Doc blocks are defined in .yml files under the 'docs:' key to keep documentation separate from SQL code.
How do you reference a doc block in a column description?
AUsing {{ doc('block_name') }} inside the description
BUsing {{ ref('block_name') }}
CUsing {{ source('block_name') }}
DUsing {{ config('block_name') }}
✗ Incorrect
The correct way to reference a doc block is with {{ doc('block_name') }} inside the description field.
What is a main benefit of using doc blocks?
AThey allow reusable documentation to keep descriptions consistent
BThey replace the need for tests
CThey automatically generate data models
DThey speed up SQL query execution
✗ Incorrect
Doc blocks help reuse documentation, making descriptions consistent and easier to maintain.
Can doc blocks contain markdown formatting?
ANo, only plain text is allowed
BYes, markdown formatting is supported
COnly HTML tags are allowed
DOnly YAML syntax is allowed
✗ Incorrect
Doc blocks support markdown, so you can add formatting like lists and links.
If you update a doc block description, what happens?
AYou must manually update each model description
BOnly the doc block file changes, no effect on models
CAll references to that doc block update automatically
DThe project will fail to compile
✗ Incorrect
Updating a doc block updates all places where it is referenced, keeping documentation consistent.
Explain what a doc block is in dbt and how it helps with project documentation.
Think about writing a description once and using it many times.
You got /4 concepts.
Describe the steps to create and use a doc block for a column description in dbt.
Start with writing the reusable text, then call it where needed.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using doc blocks in dbt?
easy
A. To write descriptions once and reuse them across models
B. To create new database tables automatically
C. To run SQL queries faster
D. To define variables for SQL scripts
Solution
Step 1: Understand what doc blocks do
Doc blocks let you write descriptions once and reuse them in multiple places.
Step 2: Identify the main purpose
This saves time and keeps documentation consistent across your project.
Final Answer:
To write descriptions once and reuse them across models -> Option A
2. Which syntax correctly defines a doc block named customer_description in dbt?
easy
A. docs:
customer_description: "Description text here"
B. doc_blocks:
customer_description: "Description text here"
C. doc:
customer_description: "Description text here"
D. docs_block:
customer_description: "Description text here"
Solution
Step 1: Recall the correct keyword for doc blocks
The correct keyword to define doc blocks is docs:.
Step 2: Match the syntax
docs:
customer_description: "Description text here" uses docs: followed by the doc block name and description, which is correct.
Final Answer:
docs:\n customer_description: "Description text here" -> Option A
Quick Check:
Define doc blocks with docs: [OK]
Hint: Use 'docs:' to define doc blocks in YAML [OK]
Common Mistakes:
Using 'doc:' instead of 'docs:'
Adding extra underscores in keyword
Misnaming the block keyword
3. Given the following doc block definition:
docs:
sales_desc: "This model contains sales data aggregated by month."
What will be the output of this Jinja code in a model description?
{{ doc("sales_desc") }}
medium
A. Error: doc block not found
B. {{ doc("sales_desc") }}
C. sales_desc
D. This model contains sales data aggregated by month.
Solution
Step 1: Understand what {{ doc("sales_desc") }} does
This Jinja function inserts the text from the doc block named sales_desc.
Step 2: Match the doc block content
The doc block sales_desc contains the description "This model contains sales data aggregated by month." so that text will be output.
Final Answer:
This model contains sales data aggregated by month. -> Option D
Quick Check:
doc("name") outputs doc block text [OK]
Hint: doc("name") outputs the stored description text [OK]
Common Mistakes:
Expecting the literal string instead of description
Confusing doc block name with output
Assuming an error if doc block exists
4. You wrote this doc block:
docs:
product_info: "Details about product sales."
But when you use {{ doc("product_info") }} in your model, it shows an error. What is the likely cause?
medium
A. You must define doc blocks inside the model SQL file
B. The doc block name is misspelled in the doc() call
C. Doc blocks cannot contain spaces in descriptions
D. You forgot to run dbt compile before using doc blocks
Solution
Step 1: Check common causes of doc block errors
One common cause is a mismatch between the doc block name and the name used in doc().
Step 2: Verify usage rules
Doc blocks are defined in YAML files, not inside SQL files, and descriptions can have spaces. Running dbt compile is standard but not usually the cause of this error.
Final Answer:
The doc block name is misspelled in the doc() call -> Option B
Quick Check:
Name mismatch causes doc block errors [OK]
Hint: Check spelling of doc block names carefully [OK]
Common Mistakes:
Defining doc blocks inside SQL files
Assuming spaces cause errors
Skipping dbt compile step
5. You want to create a reusable doc block for a customer model description that includes the phrase "Contains customer purchase history." You also want to reuse this description in multiple models. Which steps correctly achieve this?
hard
A. Write the description directly in each model SQL file without doc blocks
B. Create a SQL macro that returns the description text and call it in models
C. Define the doc block under docs: in schema.yml, then use {{ doc("customer_history") }} in model descriptions
D. Use ref() function to link to the description in other models
Solution
Step 1: Define reusable description in docs block
Place the description under docs: in a YAML file like schema.yml with a name like customer_history.
Step 2: Reuse description with doc() function
Use {{ doc("customer_history") }} in the description field of any model to reuse the text.
Final Answer:
Define the doc block under docs: in schema.yml, then use {{ doc("customer_history") }} in model descriptions -> Option C
Quick Check:
docs: + doc() = reusable descriptions [OK]
Hint: Define once in docs:, reuse with doc() in models [OK]
Common Mistakes:
Writing descriptions repeatedly in SQL files
Using macros instead of doc blocks for descriptions