What is the main purpose of using doc blocks in dbt projects?
Think about how documentation can be reused efficiently in multiple places.
Doc blocks in dbt allow you to write documentation once and reuse it in multiple models or sources, ensuring consistency and saving time.
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') }}"
Remember how doc blocks are referenced inside model descriptions.
The {{ doc('customer_description') }} syntax injects the content of the doc block named customer_description into the model's 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?
Check how multiple doc blocks are combined in a string.
Each {{ doc('...') }} is replaced by its description, and the string concatenates them with ' - ' in between.
What error will occur when running dbt with this model configuration?
models:
- name: orders
description: "{{ doc('non_existent_doc') }}"
What happens if you reference a doc block that does not exist?
dbt raises a compilation error if a referenced doc block is missing, preventing the model from running.
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?
Check the correct syntax for defining and referencing doc blocks in column descriptions.
Doc blocks are defined under docs with a name and description. They are referenced in model columns using {{ doc('name') }}. Option D follows this pattern correctly.