Column descriptions help explain what each column in your data means. This makes your data easier to understand for everyone.
Column descriptions 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
columns:
- name: column_name
description: "Description of what this column means or contains."Descriptions are added inside the model's YAML file under the columns section.
Each column has a name and a description field.
Examples
user_id column as a unique ID for users.dbt
columns:
- name: user_id
description: "Unique identifier for each user."order_date stores the date of an order.dbt
columns:
- name: order_date
description: "Date when the order was placed."total_amount is the order's price in dollars.dbt
columns:
- name: total_amount
description: "Total price of the order in USD."Sample Program
This YAML snippet shows how to add descriptions to columns in a dbt model named orders. Each column has a clear explanation to help users understand the data.
dbt
version: 2 models: - name: orders description: "Table containing customer orders." columns: - name: order_id description: "Unique ID for each order." - name: customer_id description: "ID of the customer who placed the order." - name: order_date description: "Date when the order was made." - name: total_amount description: "Total cost of the order in USD."
Important Notes
Descriptions appear in dbt documentation sites and help with data cataloging.
Keep descriptions short and clear for best results.
You can update descriptions anytime to keep documentation current.
Summary
Column descriptions explain what each column means.
They are added in the YAML file under the columns section.
Good descriptions make data easier to use and share.
Practice
1. What is the main purpose of adding
column descriptions in dbt?easy
Solution
Step 1: Understand the role of column descriptions
Column descriptions provide explanations about what each column represents in the data model.Step 2: Differentiate from other YAML uses
They do not change data types, create columns, or contain SQL code; they only describe columns.Final Answer:
To explain what each column means for better understanding -> Option CQuick Check:
Column descriptions = explain columns [OK]
Hint: Descriptions explain columns, not change data or structure [OK]
Common Mistakes:
- Thinking descriptions change data types
- Confusing descriptions with SQL code
- Assuming descriptions create new columns
2. Which of the following is the correct syntax to add a column description in a dbt YAML file?
easy
Solution
Step 1: Recall YAML structure for columns in dbt
The correct format uses a list undercolumns:with each item havingnameanddescriptionkeys.Step 2: Compare options to correct format
columns: - name: customer_id description: 'Unique ID for each customer' matches the correct YAML syntax with dash, name, and description keys properly indented.Final Answer:
columns: - name: customer_id description: 'Unique ID for each customer' -> Option BQuick Check:
YAML columns list with name and description = columns: - name: customer_id description: 'Unique ID for each customer' [OK]
Hint: Use dash list with name and description keys in YAML [OK]
Common Mistakes:
- Using key-value pairs without dash list
- Putting description outside columns section
- Incorrect indentation or missing name key
3. Given this YAML snippet in a dbt model:
columns:
- name: order_id
description: 'Unique order identifier'
- name: order_date
description: 'Date when order was placed'
What will dbt show for the order_date column in documentation?medium
Solution
Step 1: Locate the description for order_date
The YAML showsorder_datehas description 'Date when order was placed'.Step 2: Understand dbt documentation behavior
dbt uses the description text to show in docs, not the column name or other text.Final Answer:
Date when order was placed -> Option DQuick Check:
dbt docs show column description text [OK]
Hint: dbt docs show the description text, not column name [OK]
Common Mistakes:
- Confusing column name with description
- Assuming no description if present
- Picking wrong description text
4. You wrote this YAML for column descriptions but dbt docs shows no descriptions:
columns:
- name: user_id
description 'User unique ID'
What is the error causing descriptions not to appear?medium
Solution
Step 1: Check YAML syntax for description key
The linedescription 'User unique ID'is missing a colon afterdescription.Step 2: Understand YAML parsing impact
Without the colon, YAML is invalid and dbt cannot read the description, so docs show no description.Final Answer:
Missing colon after description key -> Option AQuick Check:
YAML keys need colon after them [OK]
Hint: Always put colon after YAML keys like description [OK]
Common Mistakes:
- Forgetting colon after keys
- Incorrect indentation
- Assuming case sensitivity matters
5. You want to add descriptions for multiple columns in a dbt model YAML file. Which approach correctly documents two columns
product_id and price with descriptions, ensuring dbt docs will display them properly?hard
Solution
Step 1: Recall correct YAML list format for multiple columns
Each column must be an item in a list withnameanddescriptionkeys.Step 2: Evaluate each option's structure
columns: - name: product_id description: 'ID of the product' - name: price description: 'Price in USD' correctly uses a list with two items, each having name and description properly indented.Final Answer:
columns: - name: product_id description: 'ID of the product' - name: price description: 'Price in USD' -> Option AQuick Check:
List of columns with name and description keys = columns: - name: product_id description: 'ID of the product' - name: price description: 'Price in USD' [OK]
Hint: Use dash list with name and description for each column [OK]
Common Mistakes:
- Using key-value pairs without dash list
- Repeating keys without list items
- Incorrect indentation breaking YAML
