Skip to content

Commit

Permalink
(#1717) fix for re-rendering in statement calls
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed Sep 3, 2019
1 parent 48bd3ca commit d1a49d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/dbt/include/global_project/macros/core.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro statement(name=None, fetch_result=False, auto_begin=True) -%}
{%- if execute: -%}
{%- set sql = render(caller()) -%}
{%- set sql = caller() -%}

{%- if name == 'main' -%}
{{ log('Writing runtime SQL for node "{}"'.format(model['unique_id'])) }}
Expand All @@ -16,7 +16,7 @@
{%- endmacro %}

{% macro noop_statement(name=None, status=None, res=None) -%}
{%- set sql = render(caller()) -%}
{%- set sql = caller() -%}

{%- if name == 'main' -%}
{{ log('Writing runtime SQL for node "{}"'.format(model['unique_id'])) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
commit;
{% endcall %}
{% endif %}
{% call statement(auto_begin=inside_transaction) %}
{{ hook.get('sql') }}
{% endcall %}
{% set rendered = render(hook.get('sql')) | trim %}
{% if (rendered | length) > 0 %}
{% call statement(auto_begin=inside_transaction) %}
{{ rendered }}
{% endcall %}
{% endif %}
{% endfor %}
{% endmacro %}

Expand Down

0 comments on commit d1a49d3

Please sign in to comment.