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

Remove the call to render() in the statement macro #1717

Closed
drewbanin opened this issue Aug 30, 2019 · 0 comments · Fixed by #1719
Closed

Remove the call to render() in the statement macro #1717

drewbanin opened this issue Aug 30, 2019 · 0 comments · Fixed by #1719
Labels
bug Something isn't working

Comments

@drewbanin
Copy link
Contributor

Describe the bug

dbt currently calls render() on already-compiled SQL in statement blocks. This render usually is a no-op -- if the SQL is already compiled, then calling render() on it should be a no-op. Sometimes though, compiled code contains valid jinja statements. This can happen if:

  • the source code contains a {% raw %} block
  • a user-supplied configuration is provided which contains uncompiled jinja code (the culprit in this issue)

Steps To Reproduce

Given a model like:

-- models/debug.sql

{% raw %}
select '{{ 1 + 1 }}' as debug
{% endraw %}

The resulting query that dbt runs should be:

create view "analytics"."demo_schema"."debug__dbt_tmp" as (
  select '{{ 1 + 1 }}' as debug
);

Instead, it is:

create view "analytics"."demo_schema"."debug__dbt_tmp" as (
  select '2' as debug
);

System information

This bug affects all supported database. It was reproduced on 0.14.0 and later, but this particular line of code has existed in dbt for quite a bit longer than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant