dbt select支持的方法简单说明

对于一个大型的dbt 项目,我进行按需选择模型还是很重要的,dbt 基于select 可以支持多样的选择方法

支持的模式

  • tag 模式
dbt run --select "tag:nightly" 
  • source 模式
dbt run --select "source:snowplow+" 
  • 资源类型模式
dbt build --select "resource_type:exposure" 
dbt list --select "resource_type:test" 
  • 路径模式
# These two selectors are equivalent
dbt run --select "path:models/staging/github"
dbt run --select "models/staging/github"
 
# These two selectors are equivalent
dbt run --select "path:models/staging/github/stg_issues.sql"
dbt run --select "models/staging/github/stg_issues.sql"
  • 文件模式
dbt run --select "file:some_model.sql"
dbt run --select "some_model.sql"
dbt run --select "some_model"
  • fqn 模式
dbt run --select "fqn:some_model"
dbt run --select "fqn:your_project.some_model"
dbt run --select "fqn:some_package.some_other_model"
dbt run --select "fqn:some_path.some_model"
dbt run --select "fqn:your_project.some_path.some_model"
  • package 模式
# These three selectors are equivalent
dbt run --select "package:snowplow"
dbt run --select "snowplow"
dbt run --select "snowplow.*"
  • config 模式
dbt run --select "config.materialized:incremental"   
dbt run --select "config.schema:audit"             
dbt run --select "config.cluster_by:geo_country" 
  • 测试类型模式
dbt test --select "test_type:generic"    
dbt test --select "test_type:singular"
  • 测试方法模式
dbt test --select "test_name:unique"   
dbt test --select "test_name:equality"  
dbt test --select "test_name:range_min_max" 
  • 状态模式
dbt test --select "state:new" --state path/to/artifacts  
dbt run --select "state:modified" --state path/to/artifacts 
dbt ls --select "state:modified" --state path/to/artifacts 
  • exposure模式
dbt run --select "+exposure:weekly_kpis"  
dbt test --select "+exposure:*"       
dbt ls --select "+exposure:*" --resource-type snowplow 
  • metrics 模式
dbt build --select "+metric:weekly_active_users"   
dbt ls    --select "+metric:*" --resource-type source
  • result 模式
dbt run --select "result:error" --state path/to/artifacts  
dbt test --select "result:fail" --state path/to/artifacts  
dbt build --select "1+result:fail" --state path/to/artifacts  
dbt seed --select "result:error" --state path/to/artifacts  
  • source_status 模式
dbt source freshness 
dbt build --select "source_status:fresher+"  
  • group 模式
dbt run --select "group:finance"
  • 访问模式
dbt list --select "access:public"   
dbt list --select "access:private"  
dbt list --select "access:protected" 
  • 版本模式
dbt list --select "version:latest"     
dbt list --select "version:prerelease"   
dbt list --select "version:old"
dbt list --select "version:none"  
  • 语义模型模式
dbt list --select "semantic_model:*"  
dbt list --select "+semantic_model:orders"
  • 保存查询模式
dbt list --select "saved_query:*"                
dbt list --select "+saved_query:orders_saved_query" 

说明

以上是选择的简单说明,实际上dbt 在处理的时候还支持基于graph 的操作实现比较灵活的选择执行,详细的使用还是得多练习

参考资料

https://docs.getdbt.com/reference/resource-configs/tags
https://docs.getdbt.com/reference/resource-configs/access
https://docs.getdbt.com/reference/resource-configs/group
https://docs.getdbt.com/docs/collaborate/govern/model-versions
https://docs.getdbt.com/docs/build/saved-queries
https://docs.getdbt.com/docs/build/semantic-models
https://docs.getdbt.com/reference/node-selection/set-operators
https://docs.getdbt.com/reference/node-selection/graph-operators
https://docs.getdbt.com/reference/node-selection/yaml-selectors
https://docs.getdbt.com/reference/node-selection/syntax
https://docs.getdbt.com/reference/node-selection/methods

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

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-06-11 postgresml 基于postgres 的ai 应用数据库
2023-06-11 lilo java 快速 graphql stitching 包
2023-06-11 coredb 使用pg all-in-one 解决方案
2022-06-11 async-profiler convert 方便的jfr 转换工具
2022-06-11 几个不错的数据加速工具
2022-06-11 dremio kernel 一些隐藏的配置
2022-06-11 dremio 支持创建iceberg 的方法

导航

< 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
点击右上角即可分享
微信分享提示