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

Fix source test arg rendering (#2114) #2150

Merged
merged 2 commits into from
Feb 24, 2020

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Feb 21, 2020

resolves #2114

Description

With this PR, dbt now gives an error on tests in sources of the schema.yml section.

To get to the ultimately desired behavior, see #2149 - to be resolved in 0.17.0, probably.

This is a breaking change! We used to render args in the schema-yaml-rendering-context, which was incorrect and didn't match the behavior in models.

I'm left with the uncomfortable feeling that someone out there is using {{ invocation_id }} or {{ run_started_at }} in parameters to their tests (why else would we do this?).

We could alternatively generate a full runtime context and re-render wrapped SQL. I don't think that's the worst idea of all time, but it might be slower. Definitely a hack!

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

Remove extra jinja rendering pass on wrapped_sql
@cla-bot cla-bot bot added the cla:yes label Feb 21, 2020
Update changelog further to reflect that this is breaking
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.

The existing behavior is just... so.... wonky here. The fact that this works:

sources:
    - name: snowplow
      tables:
          - name: events
            columns:
                - name: number
                  tests:
                      - custom_test:
                          arg: var('abc', 'PROVIDED')

but that this doesn't:

                      - custom_test:
                          arg: "{{ var('abc', 'PROVIDED') }}"

is just terrible. So, this is a great change for consistency in compilation, but I am very much looking forward to working on #2149 in the future!

Nice work on this one, let's ship it

@beckjake beckjake merged commit e571cba into dev/barbara-gittings Feb 24, 2020
@beckjake beckjake deleted the fix/source-test-arg-rendering branch February 28, 2020 01:42
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.

model test compilation context does not have the var method in scope
2 participants