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

Schema Test - Accepted Values for null value #287

Closed
ddppi opened this issue Sep 30, 2020 · 4 comments
Closed

Schema Test - Accepted Values for null value #287

ddppi opened this issue Sep 30, 2020 · 4 comments

Comments

@ddppi
Copy link

ddppi commented Sep 30, 2020

Hi, in one of my schema test, I want to test if the accepted values for a column is a list of numbers, or NULL, for example
models:

  • name:
    columns:
    • name:
      tests:
      • accepted_values:
        values: [0, 1, 99, null]

I find DBT tries to convert the value of the accepted values to characters, and also covert null to None. Then the test failed, because
Numeric value 'None' is not recognized

Is this an issue?

I am using Snowflake, Python 3.7 and DBT v0.18.0.

Thanks

@clrcrl
Copy link
Contributor

clrcrl commented Sep 30, 2020

Instead, you should use two separate tests:

version: 2

models:
  - name: my_model
    columns:
      - name: id
        tests:
          - accepted_values:
              values: [0, 1, 99]
          - not_null

@clrcrl clrcrl closed this as completed Sep 30, 2020
@ddppi
Copy link
Author

ddppi commented Sep 30, 2020 via email

@ddppi
Copy link
Author

ddppi commented Oct 3, 2020

Hi @clrcrl , can you please let me know how to check accepted value of 0,1,99 and NULL? NULL is an acceptable value for me in this case, and I don't think your suggestion solves my issue.

P.S. it seems NULL is a default accepted value.

@jrmidkiff
Copy link

jrmidkiff commented Sep 18, 2023

@clrcrl - I suppose the best way to do this is with a custom sql test such as

SELECT t.*
FROM table t 
WHERE t.column IS NOT NULL AND t.column NOT IN ('VALUE1', 'VALUE 2')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants