【问题标题】:How to persist column descriptions in BigQuery tables如何在 BigQuery 表中保留列描述
【发布时间】:2022-01-03 17:52:48
【问题描述】:

我在我的 dbt(data build tool) 中创建了模型,并在其中指定了列描述。在我的 dbt_project.yml 文件中如下所示

models:
    sakila_dbt_project:
     # Applies to all files under models/example/
     +persist_docs:
        relation: true
        columns: true
      events:
          materialized: table
          +schema: examples

我已经添加了 +persist_docs,正如 dbt 所描述的那样,作为使列描述出现但仍然没有描述出现在 bigquery 表中的修复。

我的models/events/events.yml 看起来像这样

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

      - name: user-id
        quote: true
        description: The user who performed the event
        tests:
          - not_null

我错过了什么?

p.s 我使用的是 dbt 版本 0.21.0

【问题讨论】:

    标签: google-bigquery yaml etl dbt


    【解决方案1】:

    看起来与the docs中所示的所需格式一致:

    dbt_project.yml

    models:
    ..[<resource-path>](resource-path):
    ....+persist_docs:
    ......relation: true
    ......columns: true
    

    models/schema.yml

    version: 2
    
    models:
    ..- name: dim_customers
    ....description: One record per customer
    ....columns:
    ......- name: customer_id
    ........description: Primary key
    

    也许是间距?我在上面的示例中将空格转换为句点,因为空格的数量对于 yml 文件来说是不可原谅的。

    我已经开始使用 vscode yml 格式化程序,因为我经常在 schema.ymldbt_project.yml 中遇到这些键的间距问题

    否则,这不适合sourceexternal-table 对吧?这是persist-docs 不支持的仅有的两个工件。

    1. 来源不受支持 persist_docs -> 来源选项卡
    2. 不支持外部表(无法再次在文档中找到,但今天在文档或 github 问题中阅读)
    3. 同样不支持 Apache Spark(此处无关)Apache Spark Profile

    另外,如果您要经常使用persist_docs,请查看这个宏示例persist_docs_op,Jeremy 留给run-operation 更新您的持久化文档,以防您更改所有内容!

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 1970-01-01
      • 2020-12-10
      • 2013-11-25
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      相关资源
      最近更新 更多