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

Implement 'mostly' in expression tests #11

Closed
clausherther opened this issue Nov 23, 2020 · 6 comments
Closed

Implement 'mostly' in expression tests #11

clausherther opened this issue Nov 23, 2020 · 6 comments

Comments

@clausherther
Copy link
Contributor

We should support the mostly parameter in expression tests as a float that controls what % of rows need to satisfy the given expression test. Default is 100%.

@seanpwlms
Copy link

Apologies if this is addressed elsewhere, but this looks like the closest issue. For the expect_grouped_row_values_to_have_recent_data test, I have one group that will not have recent data for valid reasons. Currently the test fails, saying Got 1 result, configured to fail if != 0. It would be great if I could specify fail if result > n.

@clausherther
Copy link
Contributor Author

Hi @seanpwlms ! I think this might actually be supported in the new dbt test configs:
https://docs.getdbt.com/reference/test-configs
I haven't played around with this, but I think the relevant config is error_if https://docs.getdbt.com/reference/resource-configs/severity
Would love to hear if this is works for you and how you ended up using it!

@seanpwlms
Copy link

@clausherther Thank you! Of course the answer is to read the docs. Adding error_if converts the severity to a "warn", which you can make pass by adding a warn_if setting.

@rfortmann-ewolff
Copy link

rfortmann-ewolff commented Aug 3, 2021

I tried using the severity and the warn_if arguments but dbt encounter an error:

          - name: name_tracker
            tests:
              - dbt_expectations.expect_column_values_to_be_in_set:
                  value_set: ["ssc", "sp2", "cf", "ssc1"]
                  +severity: warn
Running with dbt=0.20.0
Encountered an error:
Compilation Error
  Invalid test config given in models/snowplow/sources_in_snowplow.yml:
        test definition dictionary must have exactly one key, got [('not_null', None), ('+severity', 'warn')] instead (2 keys)

and

          - name: name_tracker
            tests:
              - dbt_expectations.expect_column_values_to_be_in_set:
                  value_set: ["ssc", "sp2", "cf", "ssc1"]
                  +warn_if: "!=0"
Running with dbt=0.20.0
Encountered an error:
Compilation Error in test dbt_expectations_source_expect_column_values_to_be_in_set_snowplow_events__0__name_tracker__ssc__sp2__cf__ssc1 (models/snowplow/sources_in_snowplow.yml)
  macro 'dbt_macro__test_expect_column_values_to_be_in_set' takes no keyword argument '+warn_if'

Any idea what the problem could be ?

@rfortmann-ewolff
Copy link

I could solve my own problem.

          - name: name_tracker
            tests:
              - dbt_expectations.expect_column_values_to_be_in_set:
                  value_set: ["ssc", "sp2", "cf", "ssc1"]
                  severity: warn

I hope it might help others.

@clausherther
Copy link
Contributor Author

@rfortmann-ewolff glad you solved it! I think the + syntax in dbt is for project config settings only, but not sure.

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