Search code examples
documentationdbt

add column descriptions in dbt docs


By running dbt docs generate and dbt docs serve, I can generate a documentation for my models that contains all column names automatically. If I do something like this:

models/.yml

version: 2

models:
  - name: events
    description: This table contains clickstream events from the marketing website

the documentation that is generated already contains a list of columns + their type. However, the column description column is empty. If I want to add a description, I can do something like this:

version: 2

models:
  - name: events
    description: This table contains clickstream events from the marketing website

    columns:
      - name: event_id
        description: This is a unique identifier for the event
        tests:
          - unique
          - not_null

However, in this way, I will have to manually type all column names. Is there any way I can automate this? Such that the column names can be automatically extracted in a list etc and I only have to write the descriptions? I will have to do this for multiple files.


Solution

  • The canonical way to do this is with the codegen package, which generates the files exactly as you have described.