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

render severity configurations (#1512) (#1511) #1519

Merged
merged 3 commits into from
Jun 13, 2019

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Jun 7, 2019

Fixes #1511 and #1512 by rendering the "severity" field in test configurations.

@beckjake beckjake changed the title render severity configurations (#1512) render severity configurations (#1512) (#1511) Jun 7, 2019
@drewbanin
Copy link
Contributor

I found one random issue when poking around with this. If you use a severity setting like this:

version: 2

models:
  - name: my_model
    columns:
      - name: id
        tests:
          - not_null:
              severity: "{{ 'WARN' if var('prod', false) }}"

then dbt will fail with:

'NoneType' object has no attribute 'get'

via

    return render_template(template, ctx, node)
  File "/Users/drew/fishtown/dbt/core/dbt/clients/jinja.py", line 334, in render_template
    return template.render(ctx)
  File "/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "dbt-d3e2f3354c22a85d92b076ce", line 1, in top-level template code
    from __future__ import division, generator_stop
  File "/Users/drew/fishtown/dbt/core/dbt/clients/jinja.py", line 266, in __str__
    self._fail_or_warn_with_undefined_error()
  File "/Users/drew/fishtown/dbt/core/dbt/clients/jinja.py", line 244, in _fail_or_warn_with_undefined_error
    self.node.get('resource_type'),
AttributeError: 'NoneType' object has no attribute 'get'

I think that the 'WARN' if var('prod', false) raises a warning, and something in _fail_or_warn_with_undefined_error doesn't play nice with tests here. I can make a new issue for this, but wanted to point it out 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.

One comment about a relatively specific edge-case. Otherwise, LGTM!

@beckjake beckjake force-pushed the feature/render-severity-configs branch from 08991b4 to 32db2e5 Compare June 12, 2019 21:38
@beckjake beckjake force-pushed the feature/render-severity-configs branch from 32db2e5 to a4be1e1 Compare June 12, 2019 22:13
@beckjake beckjake merged commit e57c7b6 into dev/wilt-chamberlain Jun 13, 2019
@beckjake beckjake deleted the feature/render-severity-configs branch June 13, 2019 01:40
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.

[Wilt Chamberlain] Render severity config for tests
2 participants