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

Adds "quote" parameter to "accepted_values" test #1876

Merged
merged 2 commits into from
Nov 1, 2019
Merged

Adds "quote" parameter to "accepted_values" test #1876

merged 2 commits into from
Nov 1, 2019

Conversation

clausherther
Copy link
Contributor

Adds quote parameter to accepted_values test. Closes #1873.

Users can now test for acceptable integer values by opting not to quote these values.

...
         - name: day_of_week
            description: 
            tests:
              - not_null
              - accepted_values:
                  values: [1, 2, 3, 4, 5, 6, 7]
                  quote: false
...

Results in:

with all_values as (
    select distinct
        day_of_week as value_field
    from dw.dim_date
),
validation_errors as (
    select
        value_field
    from 
        all_values
    where
        value_field not in (
            1,
            2,
            3,
            4,
            5,
            6,
            7
            )
)

select count(*)
from validation_errors

While the default behavior is to quote, e.g.

...
         - name: day_of_week_name
            description: 
            tests:
              - not_null
              - accepted_values:
                  values: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
...
with all_values as (
    select distinct
        day_of_week_name as value_field
    from dw.dim_date
),
validation_errors as (
    select
        value_field
    from 
        all_values
    where
        value_field not in (
            'Sunday',
            'Monday',
            'Tuesday',
            'Wednesday',
            'Thursday',
            'Friday',
            'Saturday'
            )
)

select count(*)
from validation_errors

@cla-bot
Copy link

cla-bot bot commented Oct 29, 2019

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @clausherther

@clausherther clausherther changed the title Add/quote accepted values Adds "quote" parameter to "accepted_values" test Oct 29, 2019
@drewbanin
Copy link
Contributor

Thanks! Glad to get this test working better - it's been a long time coming :)

I just kicked off the tests here. CLA looks good too (@cla-bot check).

Looking forward to merging this!

@cla-bot
Copy link

cla-bot bot commented Oct 29, 2019

The cla-bot has been summoned, and re-checked this pull request!

@cla-bot cla-bot bot added the cla:yes label Oct 29, 2019
@clausherther
Copy link
Contributor Author

@drewbanin anything I need to be doing re: that BigQuery integration test failure? Looks like they all failed, so this may be just a CI thing, but wanted to make sure.

@drewbanin
Copy link
Contributor

Hmmm, that's really strange! I see this error in the Azure logs:

The job encountered an internal error during execution and was unable to complete successfully.

So, this looks like a BQ blip, I think we're ok here :)

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM! Thanks for your contribution @clausherther :)

@drewbanin drewbanin merged commit e022e73 into dbt-labs:dev/louisa-may-alcott Nov 1, 2019
@clausherther clausherther deleted the add/quote-accepted-values branch November 1, 2019 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add quote parameter to accepted_values test
2 participants