dbt docs block 的一些技巧

dbt 的docs 实际上自定义上还是很强大的,可以灵活的docs block 解析,同时docs 定义也可以类似model 那样进行引用,当然也包含了一些内部固定模式可以灵活的进行文档的自定义

一些内置自定义玩法

  • 自定义文档路径
    类似dbt 其他资源一样docs 也是支持自定义的,否则默认会搜索model-paths, seed-paths, analysis-paths, macro-paths 以及 snapshot-paths
    配置(dbt_project.yml)
docs-paths: [directorypath]
  • overview
    可以用来定义website 的信息
    参考
{% docs __overview__ %}
# Monthly Recurring Revenue (MRR) playbook.
This dbt project is a worked example to demonstrate how to model subscription
revenue. **Check out the full write-up [here](https://blog.getdbt.com/modeling-subscription-revenue/),
as well as the repo for this project [here](https://github.com/dbt-labs/mrr-playbook/).**
...
{% enddocs %}
  • 项目级别的自定义
    参考格式__[project_name]__ 可以方便的自定义项目的描述信息
{% docs __dremio_demo_app__ %}
 
##  this is my pacakge demo
 
### contains 
 
- mymodel-v2
- mymodel-v3
 
{% enddocs %}
  • 类似模型的引用
    定义
{% docs table_events %}
 
This table contains clickstream events from the marketing website.
 
The events in this table are recorded by Snowplow and piped into the warehouse on an hourly basis. The following pages of the marketing site are tracked:
 - /
 - /about
 - /team
 - /contact-us
 
{% enddocs %}
  • 引用
version: 2
models:
  - name: events
    description: '{{ doc("table_events") }}'
    columns:
      - name: event_id
        description: This is a unique identifier for the event
        tests:
            - unique
            - not_null

说明

dbt 在分析工程上的实践好多地方还是值得学习的,docs 部分的设计就比较强大,对于数据系统的设计上很值得学习参考下

参考资料

https://docs.getdbt.com/docs/collaborate/documentation
https://docs.getdbt.com/reference/resource-properties/description#include-an-image-from-your-repo-in-your-descriptions
https://docs.getdbt.com/docs/collaborate/documentation
https://docs.getdbt.com/reference/dbt-jinja-functions/doc

posted on   荣锋亮  阅读(15)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-04-20 sbom-tool 微软提供sbom工具
2023-04-20 Squirrel 类似clickonce 的工具
2023-04-20 pypiserver 最小开源pip 私服
2021-04-20 cube.js data-blending一些说明
2021-04-20 cube.js 新版本的一些特性
2021-04-20 cube.js TimeoutError: ResourceRequest timed out 问题参考解决方法
2020-04-20 AxonFrameworksAxonFramework jvm 上强大的演进式事件驱动的微服务框架

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示