我正在尝试使用 yaml 选择器,到目前为止还没有成功。我的选择器.yml:
selectors:
- name: daily
description: selects models for daily run
definition:
exclude:
- union:
- "tag:pp_backfill"
- "tag:inc_transactions_raw_data"
- "tag:hourly"
当我尝试使用它时,出现错误:
$ dbt ls --selector daily
* Deprecation Warning: dbt v0.17.0 introduces a new config format for the
dbt_project.yml file. Support for the existing version 1 format will be removed
in a future release of dbt. The following packages are currently configured with
config version 1:
- honey_dbt
- dbt_utils
- audit_helper
- codegen
For upgrading instructions, consult the documentation:
https://docs.getdbt.com/docs/guides/migration-guide/upgrading-to-0-17-0
* Deprecation Warning: The "adapter_macro" macro has been deprecated. Instead,
use the `adapter.dispatch` method to find a macro and call the result.
adapter_macro was called for: dbt_utils.intersect
Encountered an error:
Runtime Error
Could not find selector named daily, expected one of []
我在 0.18.1 和 0.19.0 中尝试过此操作,无论是否有 config-version: 2
。有什么想法吗?
最佳答案
我认为这里的障碍可能是您当前没有选择任何东西来排除特定模型使用标记方法。这是我的项目中的解决方案,然后是可能适合您的情况的采用。
上下文
我在 dbt Cloud 上运行 dbt 版本 0.19.0。这两个都编译并成功运行dbt run --selector daily
。
Jaffle 商店示例
stg_customers
标记为 dont_run_me
,stg_orders
标记为 also_dont_run_me
selector.yml
位于 dbt 项目的根目录
selectors:
- name: daily
description: selects models for daily run
definition:
union:
- method: path
value: models
- exclude:
- method: tag
value: dont_run_me
- method: tag
value: also_dont_run_me
这里的逻辑是,我首先选择所有模型,然后排除具有标签 dont_run_me
和 also_dont_run_me
的模型的并集>.
dbt run --selector daily
最终运行了我的项目中的所有内容,除了 stg_customers
和 stg_orders
具体案例
如果您尝试选择除标记为 pp_backfill
、inc_transactions_raw_data
和 hourly
的模型之外的所有模型,我认为以下内容就可以了:
selectors:
- name: daily
description: selects models for daily run
definition:
union:
- method: path
value: models
- exclude:
- union:
- method: tag
value: pp_backfill
- method: tag
value: inc_transactions_raw_data
- method: tag
value: hourly
关于dbt - 如何使用 yaml 选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65962285/