description
- Models
- Sources
- Seeds
- Snapshots
- Analyses
- Macros
- Data tests
version: 2
models:
- name: model_name
description: markdown_string
columns:
- name: column_name
description: markdown_string
version: 2
sources:
- name: source_name
description: markdown_string
tables:
- name: table_name
description: markdown_string
columns:
- name: column_name
description: markdown_string
version: 2
seeds:
- name: seed_name
description: markdown_string
columns:
- name: column_name
description: markdown_string
version: 2
snapshots:
- name: snapshot_name
description: markdown_string
columns:
- name: column_name
description: markdown_string
version: 2
analyses:
- name: analysis_name
description: markdown_string
columns:
- name: column_name
description: markdown_string
version: 2
macros:
- name: macro_name
description: markdown_string
arguments:
- name: argument_name
description: markdown_string
Definition
A user-defined description. Can be used to document:
- a model, and model columns
- sources, source tables, and source columns
- seeds, and seed columns
- snapshots, and snapshot columns
- analyses, and analysis columns
- macros, and macro arguments
These descriptions are used in the documentation website rendered by dbt (refer to the documentation guide or dbt Explorer).
Descriptions can include markdown, as well as the doc
jinja function.
Be mindful of YAML semantics when providing a description. If your description contains special YAML characters like curly brackets, colons, or square brackets, you may need to quote your description. An example of a quoted description is shown below.
Examples
Add a simple description to a model and column
version: 2
models:
- name: dim_customers
description: One record per customer
columns:
- name: customer_id
description: Primary key
Add a multiline description to a model
You can use YAML block notation to split a longer description over multiple lines:
version: 2
models:
- name: dim_customers
description: >
One record per customer. Note that a customer must have made a purchase to
be included in this <Term id="table" /> — customer accounts that were created but never
used have been filtered out.
columns:
- name: customer_id
description: Primary key.
Use some markdown in a description
You can use markdown in your descriptions, but you may need to quote your description to ensure the YAML parser doesn't get confused by special characters!
version: 2
models:
- name: dim_customers
description: "**[Read more](https://www.google.com/)**"
columns:
- name: customer_id
description: Primary key.
Use a docs block in a description
If you have a long description, especially if it contains markdown, it may make more sense to leverage a docs
block. A benefit of this approach is that code editors will correctly highlight markdown, making it easier to debug as you write.
version: 2
models:
- name: fct_orders
description: This table has basic information about orders, as well as some derived facts based on payments
columns:
- name: status
description: '{{ doc("orders_status") }}'
{% docs orders_status %}
Orders can be one of the following statuses:
| status | description |
|----------------|---------------------------------------------------------------------------|
| placed | The order has been placed but has not yet left the warehouse |
| shipped | The order has been shipped to the customer and is currently in transit |
| completed | The order has been received by the customer |
| returned | The order has been returned by the customer and received at the warehouse |
{% enddocs %}
Link to another model in a description
You can use relative links to link to another model. It's a little hacky — but to do this:
- Serve your docs site.
- Navigate to the model you want to link to, e.g.
http://127.0.0.1:8080/#!/model/model.jaffle_shop.stg_stripe__payments
- Copy the url_path, i.e. everything after
http://127.0.0.1:8080/
, so in this case#!/model/model.jaffle_shop.stg_stripe__payments
- Paste it as the link
version: 2
models:
- name: customers
description: "Filtering done based on [stg_stripe__payments](#!/model/model.jaffle_shop.stg_stripe__payments)"
columns:
- name: customer_id
description: Primary key
Include an image from your repo in your descriptions
This section applies to dbt Core users only. Including an image from your repository ensures your images are version-controlled.
Both dbt Cloud and dbt Core users can include an image from the web, which offers dynamic content, reduced repository size, accessibility, and ease of collaboration.
To include an image in your model's description
field:
- Add the file in a subdirectory, e.g.
assets/dbt-logo.svg
- Set the
asset-paths
config in yourdbt_project.yml
file so that this directory gets copied to thetarget/
directory as part ofdbt docs generate
asset-paths: ["assets"]
- Use a Markdown link to the image in your
description:
version: 2
models:
- name: customers
description: "![dbt Logo](assets/dbt-logo.svg)"
columns:
- name: customer_id
description: Primary key
-
Run
dbt docs generate
— theassets
directory will be copied to thetarget
directory -
Run
dbt docs serve
— the image will be rendered as part of your project documentation:
If mixing images and text, also consider using a docs block.
Include an image from the web in your descriptions
This section applies to dbt Cloud and dbt Core users. Including an image from the web offers dynamic content, reduced repository size, accessibility, and ease of collaboration.
To include images from the web, specify the image URL in your model's description
field:
version: 2
models:
- name: customers
description: "![dbt Logo](https://github.com/dbt-labs/dbt-core/blob/main/etc/dbt-core.svg)"
columns:
- name: customer_id
description: Primary key
If mixing images and text, also consider using a docs block.