DBT中文社区

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

    开源软件DBT中文社区

    微信号:DBT_CN

    QQ群:551308350

    指标Metrics使用说明

    使用指南
    1
    1
    998
    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

      关于指标
      指标是对支持零个或多个维度的表的聚合。指标的一些示例包括:

      • 活跃用户
      • 每月经常性收入 (MRR)
        自 v1.0 版本后,dbt 支持指标定义作为新的节点类型。与暴露一样,指标在有向无环图 (DAG) 中显示为节点,并且可以在 YAML 文件中表示。在 dbt 项目中定义指标会在经过测试的版本控制代码中对关键业务逻辑进行编码。此外,您可以将这些指标定义公开给下游工具,从而提高指标报告的一致性和准确性。

      指标的好处

      • 在下游工具
        中使用指标规范 dbt 的编译上下文可以通过 graph.metrics 变量访问指标。清单项目包括下游元数据消耗的指标。
      • 查看和选择依赖项
        与曝光一样,您可以查看汇总到metrics()中的所有内容,并在 dbt 文档中查看它们。
        替代文字

      定义指标
      可以在模型配置文件中定义指标
      models/<filename>.yml

      models/marts/product/schema.yml

      version: 2

      models:

      • name: dim_customers
        ...

      metrics:

      • name: rolling_new_customers
        label: New Customers
        model: ref('dim_customers')
        description: "The 14 day rolling count of paying customers using the product"

        calculation_method: count_distinct
        expression: user_id

        timestamp: signup_date
        time_grains: [day, week, month, quarter, year]

        dimensions:

        • plan
        • country

        window:
        count: 14
        period: day

        filters:

        • field: is_paying
          operator: 'is'
          value: 'true'
        • field: lifetime_value
          operator: '>='
          value: '100'
        • field: company_name
          operator: '!='
          value: "'Acme, Inc'"
        • field: signup_date
          operator: '>='
          value: "'2020-01-01'"

        general properties

        config:
        enabled: true | false
        treat_null_values_as_zero: true | false

        meta: {team: Finance}

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