为正值编写 dbt 测试

Write dbt test for positive values

有没有一种简单的方法可以为 dbt 中的正列编写测试?

accepted_values 似乎不适用于连续变量。

我知道您可以在 ./tests 中编写查询,但对于这么简单的事情来说,这看起来有点矫枉过正。

您可以使用 dbt_utils.expression_is_true

version: 2

models:
  - name: model_name
    tests:
      - dbt_utils.expression_is_true:
          expression: "col_a > 0"

我认为 dbt_utils 的建议很好,我能想到的唯一合理的选择是编写自定义模式测试:

https://docs.getdbt.com/docs/guides/writing-custom-schema-tests/

但是既然可以使用 expression_is_true,为什么还要麻烦呢? @杰克