0
0
dbtdata~20 mins

Doc blocks for reusable descriptions in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Doc Blocks Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of doc blocks in dbt

What is the main purpose of using doc blocks in dbt projects?

ATo create reusable documentation snippets that can be referenced across models and sources
BTo define SQL queries that run before the main model executes
CTo write test cases for data quality checks
DTo store configuration settings for dbt profiles
Attempts:
2 left
💡 Hint

Think about how documentation can be reused efficiently in multiple places.

Predict Output
intermediate
2:00remaining
Output of referencing a doc block in a model description

Given the following doc block and model configuration, what will be the final description of the model?

docs:
  - name: customer_description
    description: "Contains customer demographic information"

models:
  - name: customers
    description: "{{ doc('customer_description') }}"
AContains customer demographic information
B{{ doc('customer_description') }}
CError: doc block not found
DNo description available
Attempts:
2 left
💡 Hint

Remember how doc blocks are referenced inside model descriptions.

data_output
advanced
2:00remaining
Result of rendering multiple doc blocks in a source description

Consider these doc blocks and a source configuration:

docs:
  - name: source_name_desc
    description: "Source system name"
  - name: source_table_desc
    description: "Table containing sales data"

sources:
  - name: sales_source
    description: "{{ doc('source_name_desc') }} - {{ doc('source_table_desc') }}"

What is the final description of the source sales_source after rendering?

A{{ doc('source_name_desc') }} - {{ doc('source_table_desc') }}
BSource system name - Table containing sales data
CSource system name Table containing sales data
DError: Cannot concatenate doc blocks
Attempts:
2 left
💡 Hint

Check how multiple doc blocks are combined in a string.

🔧 Debug
advanced
2:00remaining
Identifying the error in doc block usage

What error will occur when running dbt with this model configuration?

models:
  - name: orders
    description: "{{ doc('non_existent_doc') }}"
AModel runs successfully with empty description
BRuntime error: Undefined variable 'non_existent_doc'
CCompilation error: doc block 'non_existent_doc' not found
DSyntax error in model configuration
Attempts:
2 left
💡 Hint

What happens if you reference a doc block that does not exist?

🚀 Application
expert
3:00remaining
Creating a reusable doc block for column descriptions

You want to create a reusable doc block for a column named customer_id used in multiple models. Which of the following dbt YAML snippets correctly defines and references this doc block in a model's column description?

A
models:
  - name: orders
    columns:
      - name: customer_id
        description: "{{ docs('customer_id_desc') }}"
B
models:
  - name: orders
    columns:
      - name: customer_id
        description: "Unique identifier for each customer"

docs:
  - name: customer_id_desc
    description: "{{ doc('customer_id_desc') }}"
C
docs:
  - name: customer_id_desc
    description: "Unique identifier for each customer"

models:
  - name: orders
    columns:
      - name: customer_id
        description: "customer_id_desc"
D
docs:
  - name: customer_id_desc
    description: "Unique identifier for each customer"

models:
  - name: orders
    columns:
      - name: customer_id
        description: "{{ doc('customer_id_desc') }}"
Attempts:
2 left
💡 Hint

Check the correct syntax for defining and referencing doc blocks in column descriptions.