'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 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Josh D.