Reputation: 25
I am trying to create a function that will template jinja for me. The jinja statement I want to use as a function is the below.
{% if not loop.last %},{% endif %}
I created a macro in macros/macros.sql but it will not compile and produces an error. When I check the compiled sql, the select statement was not produced at all, so I can't see what it compiled to. It just shows what was there before I added the select statement as if the code was never added. Any idea of what is going on and how to fix this to work?
{% macro listify(loop) %}
{% if not loop.last %},{% endif %}
{% endmacro %}
usage in model1:
select
{% for col in var('my_cols') %}
nullif({{col}}, ""){{ listify(loop) }}
{% endfor %}
from {{ source('my_source', 'my_table') }}
Upvotes: 0
Views: 1185
Reputation: 25
I figured this out! Turns out there were other errors that needed to be addressed before it would compile. I can see the results of the compiled code now. The macro works fine!
Upvotes: 0