You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已配置dbt_utils.unique_combination_of_columns,dbt-checkpoint检查仍失败

问题描述

我有一个包含DBT Models的仓库,其中my_employees模型的.yml配置如下:

version: 2
models:
  - name: my_employees
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - employee_id
            - dept_id

使用dbt-checkpoint的pre-commit钩子保障数据质量时,.pre-commit-config.yaml的相关配置如下:

default_language_version:
  python: python3.10
repos:
:
- repo: https://github.com/dbt-checkpoint/dbt-checkpoint
  rev: v2.0.6
  hooks:
  - id: check-model-has-tests-by-group
    args: [--manifest, "dbt/target/manifest.json", "--tests", "unique", "not_null", "dbt_utils.unique_combination_of_columns", "--test-cnt", "1", "--"]
:

其他pre-commit钩子均可正常工作,但该钩子抛出异常:

my_employees: has only 0 test(s) from ['unique', 'not_null', 'dbt_utils.unique_combination_of_columns']

请问这是已知问题吗?


解决方案

这不是dbt-checkpoint的已知bug,而是配置匹配和manifest文件同步的问题,解决步骤如下:

  1. 更新manifest.json文件
    钩子依赖dbt/target/manifest.json读取模型与测试的关联信息,先确保文件是最新的:

    dbt compile
    
  2. 修正钩子的测试名称参数
    钩子匹配测试时,需要使用manifest中存储的短名称(不带包前缀),把--tests参数里的dbt_utils.unique_combination_of_columns改为unique_combination_of_columns,修改后的钩子配置如下:

  • id: check-model-has-tests-by-group
    args: [--manifest, "dbt/target/manifest.json", "--tests", "unique", "not_null", "unique_combination_of_columns", "--test-cnt", "1", "--"]
3. **验证manifest中的测试名称(可选)**
如果问题仍存在,打开`dbt/target/manifest.json`,搜索`my_employees`对应的测试条目,查看测试的`name`字段值,将钩子`--tests`参数改为该值即可。

---

内容的提问来源于stack exchange,提问作者New Contributer
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 03:27:17