Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 983
x89 Avatar asked Oct 25 '25 12:10

x89


2 Answers

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

like image 63
Josh D. Avatar answered Oct 27 '25 02:10

Josh D.


If you are working in VS Code, I can recommend using the dbt Power User VS Code Extension: https://www.dbt-power-user.com/

It has a great GUI and you can synchronize your models with the database and extract all column names and data types.

like image 26
Thomas L. Avatar answered Oct 27 '25 02:10

Thomas L.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!