Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write dbt test for positive values

Tags:

dbt

Is there an easy way to write a test for a column being positive in dbt?

accepted_values doesn't seem to work for continuous vatiables.

I know you can write queries in ./tests but it looks like an overkill for such a simple thing.

like image 205
David Masip Avatar asked Jan 25 '23 22:01

David Masip


1 Answers

You could use dbt_utils.expression_is_true

version: 2

models:
  - name: model_name
    tests:
      - dbt_utils.expression_is_true:
          expression: "col_a > 0"
like image 120
Stephan Avatar answered May 16 '23 08:05

Stephan