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 2024-06-11 06:10  荣锋亮  阅读(27)  评论(0编辑  收藏  举报

导航