I have a problem where i have some SQL statements inside of a macro. I want to avoid having this execute when i run a dbt compile command.
{% macro dbt_example_macro() -%}
{{ return(adapter.dispatch('dbt_example_macro')()) }}
{% endmacro %}
{% macro default__dbt_example_macro() -%}
{% call statement('main') %}
with foo as (
select
parse_json(test) as json_value
, parse_json(test):assemblyId
from billing
)
select
*
from foo;
{%- endcall -%}
{% set result = load_result('main') %}
{%- endmacro %}
This is super dumbed down version of my code, but the problem i am coming across is that when i run a dbt compile on a model with this code in it, it always executes the call statement. I have also tried setting it as a set statement and using run_query but i still have the same problem with that also.
I tried to parse out the insert_by_period_materialization to see how that works when you execute a dbt compile and it doesn’t seem to have the same problem that i am running across.