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
Adding Column Descriptions in dbt
📖 Scenario: You are working on a data project using dbt. Your team wants to make the data models easier to understand by adding clear descriptions to each column in the model.
🎯 Goal: You will add column descriptions to a dbt model's schema.yml file. This helps everyone know what each column means without guessing.
📋 What You'll Learn
Create a dbt model schema.yml file with a model named orders
Add column descriptions for the columns order_id, customer_id, and order_date
Use the exact description texts provided in the instructions
💡 Why This Matters
🌍 Real World
In real data projects, adding column descriptions makes data models easier to understand and maintain by everyone on the team.
💼 Career
Data analysts and engineers often write and maintain dbt models with clear documentation to improve collaboration and data quality.
Progress0 / 4 steps
1
Create the initial schema.yml file with the model name
Create a file named schema.yml and define a model with the name orders inside the models list.
dbt
Hint
Start by writing version: 2 at the top, then add models: and define the model name orders.
2
Add columns list with column names
Inside the orders model, add a columns list with the column names order_id, customer_id, and order_date. Do not add descriptions yet.
dbt
Hint
List each column under columns: with - name: column_name.
3
Add descriptions to each column
Add a description field for each column with these exact texts: order_id: "Unique ID for each order", customer_id: "ID of the customer who placed the order", order_date: "Date when the order was placed".
dbt
Hint
Indent the description under each column name and use the exact text given.
4
Display the final schema.yml content
Print the entire content of the schema.yml file as a string.
dbt
Hint
Use a print statement with triple quotes to show the full YAML content exactly.
Practice
(1/5)
1. What is the main purpose of adding column descriptions in dbt?
easy
A. To change the data type of columns
B. To create new columns in the model
C. To explain what each column means for better understanding
D. To write SQL queries inside the YAML file
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 C
Quick 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
A. description:
customer_id: 'Unique ID for each customer'
B. columns:
- name: customer_id
description: 'Unique ID for each customer'
C. columns:
customer_id: 'Unique ID for each customer'
D. columns:
- customer_id: 'Unique ID for each customer'
Solution
Step 1: Recall YAML structure for columns in dbt
The correct format uses a list under columns: with each item having name and description keys.
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 B
Quick 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
A. No description available
B. Unique order identifier
C. order_date
D. Date when order was placed
Solution
Step 1: Locate the description for order_date
The YAML shows order_date has 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 D
Quick 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:
What is the error causing descriptions not to appear?
medium
A. Missing colon after description key
B. Wrong indentation of columns
C. Missing dash before name
D. Description text should be uppercase
Solution
Step 1: Check YAML syntax for description key
The line description 'User unique ID' is missing a colon after description.
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 A
Quick 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
A. columns:
- name: product_id
description: 'ID of the product'
- name: price
description: 'Price in USD'
B. columns:
product_id: 'ID of the product'
price: 'Price in USD'
C. columns:
- product_id: 'ID of the product'
- price: 'Price in USD'
D. columns:
name: product_id
description: 'ID of the product'
name: price
description: 'Price in USD'
Solution
Step 1: Recall correct YAML list format for multiple columns
Each column must be an item in a list with name and description keys.
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 A
Quick 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]