在 dbt 文档中添加列描述

add column descriptions in dbt docs

通过 运行 dbt docs generatedbt docs serve,我可以为我的模型生成自动包含所有列名称的文档。如果我这样做:

模型/.yml

version: 2

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

生成的文档已经包含列列表及其类型。但是,列描述列是空的。如果我想添加描述,我可以这样做:

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

但是,这样一来,我将不得不手动输入所有列名。有什么办法可以使它自动化吗?这样可以在列表等中自动提取列名,而我只需要编写描述?我将不得不为多个文件执行此操作。

执行此操作的规范方法是使用 codegen 程序包,它会完全按照您描述的方式生成文件。