dbt Semantic Layer 详细教程-2 :语义模型(Semantic models)规范及示例

上文介绍了dbt语义层及语义模型作用和意义,以及语义模型的组成部分。并没有涉及语义模型规范,本文继续介绍语义模型规范,以及如何配置语义模型。

dbt语义模型

语义模型是MetricFlow中数据定义的基础,它增强了dbt语义层:

  • 将语义模型视为语义图中由实体连接的节点。

  • MetricFlow使用YAML配置文件创建查询指标的图。

  • 每个语义模型对应于DAG中的dbt模型,需要对每个语义模型进行唯一的YAML配置。

  • 可以从单个dbt模型(SQL或Python)创建多个语义模型,只要为每个语义模型提供一个唯一的名称。

  • 在dbt项目目录下的YAML文件中配置语义模型。

  • 定义好语义模型,通过metric定义进行组织。

图1

语义模型规范

semantic_models:
  - name: the_name_of_the_semantic_model ## Required
    description: same as always ## Optional
    model: ref('some_model') ## Required
    defaults: ## Required
      agg_time_dimension: dimension_name ## Required if the model contains measures
    entities: ## Required
      - see more information in entities
    measures: ## Optional
      - see more information in the measures section
    dimensions: ## Required
      - see more information in the dimensions section
    primary_entity: >-
      if the semantic model has no primary entity, then this property 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值