Documentation helps people find and understand data easily. It explains what data means and how to use it.
Why documentation makes data discoverable in dbt
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
dbt
models:
- name: model_name
description: "A clear explanation of the data model"
columns:
- name: column_name
description: "What this column means and how to use it"Documentation is written in YAML format in files like schema.yml.
Descriptions help users understand the purpose of tables and columns.
Examples
dbt
version: 2 models: - name: customers description: "Contains customer information like name and email" columns: - name: customer_id description: "Unique ID for each customer"
dbt
version: 2 models: - name: orders description: "Details of customer orders" columns: - name: order_date description: "Date when the order was placed"
Sample Program
This sample shows how to document a 'sales' model with descriptions for the model and its columns.
dbt
version: 2 models: - name: sales description: "Sales data including product and revenue" columns: - name: product_id description: "ID of the product sold" - name: revenue description: "Revenue generated from the sale" # This YAML file helps dbt generate documentation that makes sales data easy to find and understand.
Important Notes
Good documentation saves time by reducing questions about data meaning.
Keep descriptions clear and simple for everyone to understand.
Update documentation whenever data models change to keep it accurate.
Summary
Documentation explains data so people can find and use it easily.
It is written in YAML inside dbt model files.
Clear descriptions help everyone understand data purpose and usage.
Practice
1. Why is documentation important in dbt projects for data discoverability?
easy
Solution
Step 1: Understand the purpose of documentation in dbt
Documentation provides clear explanations about data models and columns.Step 2: Connect documentation to data discoverability
Clear explanations help users find and understand data easily, improving discoverability.Final Answer:
It explains data clearly so users can find and understand it easily. -> Option BQuick Check:
Documentation improves discoverability [OK]
Hint: Documentation means clear explanations for easy data finding [OK]
Common Mistakes:
- Confusing documentation with data processing speed
- Thinking documentation fixes data errors automatically
- Assuming documentation encrypts data
2. Which of the following is the correct way to add a description to a dbt model in YAML?
easy
Solution
Step 1: Recall YAML structure for dbt model descriptions
The correct syntax uses 'models:' followed by a list with '- name:' and 'description:' keys.Step 2: Identify the option matching this structure
models: - name: sales description: 'Contains sales data by region' correctly uses a list item with 'name' and 'description' under 'models'.Final Answer:
models:\n - name: sales\n description: 'Contains sales data by region' -> Option AQuick Check:
Correct YAML list syntax [OK]
Hint: YAML lists use dash and indentation for model descriptions [OK]
Common Mistakes:
- Missing dash for list items
- Using singular 'model' instead of 'models'
- Incorrect indentation breaking YAML format
3. Given this YAML snippet in a dbt model file:
models:
- name: customers
description: 'Customer details including name and email'
- name: orders
description: 'Order records with dates and amounts'
What will dbt documentation show for the 'orders' model?medium
Solution
Step 1: Locate the 'orders' model in the YAML snippet
The 'orders' model is listed with a description: 'Order records with dates and amounts'.Step 2: Understand dbt documentation usage
dbt uses the description text to show model info in docs.Final Answer:
Order records with dates and amounts -> Option CQuick Check:
Model description matches YAML text [OK]
Hint: Match model name to its description in YAML [OK]
Common Mistakes:
- Mixing descriptions between models
- Assuming missing description means error
- Confusing model names
4. You wrote this YAML for a dbt model description but the docs show no description:
models: name: products description: 'Product catalog details'What is the likely error?
medium
Solution
Step 1: Check YAML list syntax for models
dbt expects 'models:' followed by a list indicated by '-'. Missing dash means no list item.Step 2: Identify the missing dash before 'name'
Without '-', YAML treats 'name' as a key under 'models', not a list item, so description is ignored.Final Answer:
Missing dash (-) before 'name' to define list item -> Option AQuick Check:
Dash defines list items in YAML [OK]
Hint: Always use dash for list items in YAML [OK]
Common Mistakes:
- Using wrong key names
- Thinking YAML disallows descriptions
- Ignoring YAML indentation rules
5. You want to improve data discoverability by adding descriptions to columns in a dbt model. Which YAML snippet correctly documents the 'customer_id' column with a description?
hard
Solution
Step 1: Recall correct YAML structure for column documentation in dbt
Columns are listed as items with '- name:' and 'description:' keys.Step 2: Identify the option matching this structure
models: - name: customers columns: - name: customer_id description: 'Unique ID for each customer' correctly uses '- name: customer_id' and 'description' key.Final Answer:
models:\n - name: customers\n columns:\n - name: customer_id\n description: 'Unique ID for each customer' -> Option DQuick Check:
Correct column description syntax [OK]
Hint: Use '- name:' and 'description:' for columns in YAML [OK]
Common Mistakes:
- Using key-value pairs without dash for columns
- Using 'desc' instead of 'description'
- Incorrect indentation breaking YAML
