Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] test not_null: error_if not working #4051

Closed
1 task done
pato0301 opened this issue Oct 13, 2021 · 4 comments · Fixed by #4070
Closed
1 task done

[Bug] test not_null: error_if not working #4051

pato0301 opened this issue Oct 13, 2021 · 4 comments · Fixed by #4070
Assignees
Labels
bug Something isn't working regression
Milestone

Comments

@pato0301
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I have a test within a model that has the following syntax:

  • name: column name
    description: description
    tests:
    • not_null:
      - error_if: '>1'

This test was working okay in the 0.20 version but when I upgraded to the 0.21 version when I run dbt test it fails with the following error:
Got 1 result, configured to fail if != 0

Expected Behavior

The expected behaviour is that the test only fails when there is more than one null value in the model, that is to say, that the test allows only one null value.

Steps To Reproduce

  1. Have a model with a source that has a filed with one null value
  2. Have a test for not_null
  3. Add the error_if: '>1' to that test
  4. run dbt test
  5. If you have none or 1 null value in that column the test should pass, else if you have more than 1 null, the test should throw an error.

Relevant log output

Got 1 result, configured to fail if  != 0

Environment

- OS:macOS Big Sur
- Python: 3.8.8
- dbt: 0.21.0

What database are you using dbt with?

bigquery

Additional Context

No response

@pato0301 pato0301 added bug Something isn't working triage labels Oct 13, 2021
@jtcohen6
Copy link
Contributor

@pato0301 Thanks for the bug report! This does indeed seem to be a regression. dbt is doing something very weird:

version: 2
models:
  - name: my_model
    columns:
      - name: id
        tests:
          - not_null:
              error_if: '>1'

Then in manifest.json:

      "config": {
        "enabled": true,
        "alias": null,
        "schema": "dbt_test__audit",
        "database": null,
        "tags": [],
        "meta": {},
        "materialized": "test",
        "severity": "ERROR",
        "store_failures": null,
        "where": null,
        "limit": null,
        "fail_calc": "count(*)",
        "warn_if": "!= 0",
        "error_if": "!= 0",
        "error_id": ">1"
      },

error_id ????

I'll do some more digging and try to figure out where this is happening

@jtcohen6 jtcohen6 added this to the 0.21.1 milestone Oct 13, 2021
@jtcohen6
Copy link
Contributor

jtcohen6 commented Oct 13, 2021

This should be a simple one :)

if self.error_if is not None:
config['error_id'] = self.error_if

That should read:

     config['error_if'] = self.error_if 

It also looks like alias is included there twice.

Let's add a test for this!

@willycerezo
Copy link

Do you have an ETA of fix this error? thanks in advance and regards!

@jtcohen6
Copy link
Contributor

jtcohen6 commented Nov 12, 2021

@willycerezo This fix will be included in v0.21.1 and v1.0.0. Both are currently available as release candidates:

pip install dbt-<adapter>==0.21.1rc1
pip install dbt-<adapter>==1.0.0rc1

We're likely to have a final version of v0.21.1 in the next week. The final v1 release will be in early December.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants