DBT中文社区

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • 达之云

    开源软件DBT中文社区

    微信号:DBT_CN

    QQ群:551308350

    来源Sources使用说明

    使用指南
    1
    1
    683
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dazdata last edited by dazdata

      使用来源
      通过来源,可以命名和描述通过提取和加载工具加载到仓库中的数据。通过在 dbt 中将这些表声明为来源,您可以

      • 使用该函数从模型中的源表中进行选择,帮助定义数据的世系{{ source() }}
      • 测试您对源数据的假设
      • 计算源数据的新鲜度

      声明来源
      源在项目配置文件.yml中定义sources:
      version: 2

      sources:

      • name: jaffle_shop
        database: raw
        schema*: jaffle_shop
        tables:

        • name: orders
        • name: customers
      • name: stripe
        tables:

        • name: payments

      从来源中选择
      定义来源后,可以使用 {{ source()}} 函数从模型中引用它。
      models/orders.sql
      select
      ...

      from {{ source('jaffle_shop', 'orders') }}

      left join {{ source('jaffle_shop', 'customers') }} using (customer_id)
      使用该函数还会在模型和源表之间创建依赖关系。{{ source () }}
      替代文字

      来源添加测试和描述
      version: 2

      sources:

      • name: jaffle_shop
        description: This is a replica of the Postgres database used by our app
        tables:

        • name: orders
          description: >
          One record per order. Includes cancelled and deleted orders.
          columns:

          • name: id
            description: Primary key of the orders table
            tests:
            • unique
            • not_null
          • name: status
            description: Note that the status can change over time
        • name: ...

      • name: ...

      其中description为描述,tests为测试。

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by Dazdata MDS | 武汉达之云计算有限公司