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

support extra parameter 'condition' on 'expression_is_true' macro #147

Merged
merged 2 commits into from
Jun 28, 2019
Merged

support extra parameter 'condition' on 'expression_is_true' macro #147

merged 2 commits into from
Jun 28, 2019

Conversation

dcereijodo
Copy link
Contributor

@dcereijodo dcereijodo commented Jun 28, 2019

An optional parameter 'condition' can be passed to the
'expression_is_true' macro to assert the expression for all records
which meet a condition. Closes #146

Checklist

  • My commits are related to the pull request and look clean.
  • My SQL follows the Fishtown Analytics style guide.
  • I have added appropriate tests and documentation to any new models.
  • I have updated the README file.

An optional parameter 'condition' can be passed to the 
'expression_is_true' macro to assert the expression for all records 
which meet a condition. Closes #146
@dcereijodo
Copy link
Contributor Author

CI failed :(
Looks like configuration stuff though: Env var required but not provided: 'CI_REDSHIFT_DBT_HOST'

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.

One minor comment, but otherwise this looks very good to me. Going to kick off the test suite! Thanks for making this PR @dcereijodo :)

@@ -1,12 +1,18 @@
{% macro test_expression_is_true(model) %}

{% set expression = kwargs.get('expression', kwargs.get('arg')) %}
{% set condition = kwargs.get('condition', 'true') %}
Copy link
Contributor

@drewbanin drewbanin Jun 28, 2019

Choose a reason for hiding this comment

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

I think condition can be supplied as a proper keyword argument here, with the default set to true. We use this kwargs.get pattern to support both the model-level and column-level test specification syntax, but in the general case, I think it makes sense to keep arguments in the method signature where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually a bit confused by the use of kwargs here, but I thought there should be a reason for it and kept it the same. I agree a normal argument is better. I'll send the changes with your suggestions. Thanks!

@drewbanin
Copy link
Contributor

Cool, thanks for making that change! This will be good to merge when the tests pass.

Side note: love your PR description.... we're going to add something like that as the default for PRs to this repo :)

@dcereijodo
Copy link
Contributor Author

Thanks :)

@drewbanin
Copy link
Contributor

Merging this! Will cut a new release with this change on Monday :)

🎉

@drewbanin drewbanin merged commit fad8497 into dbt-labs:master Jun 28, 2019
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

Successfully merging this pull request may close these issues.

Extend 'expression_is_true' test to support subset asertions
2 participants