You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
sqlfmt encountered an error: Encountered unterminated Jinja block at position 720. Expected end tag: ({% endfor %})
To Reproduce
Steps to reproduce the behavior. If this is a formatting issue, include the input code here.
{% macro get_unique_attributes(source_table, node_col) %}
{% set attribute_query %}
select
distinct x.key as attributes
from {{ source_table }} x
where startswith(x.key, '@') -- attributes get parsed as keys that start with '@'
and length(x.key) > 1 -- but keys of just '@' designate the node itself
and regexp_count(x.path, '\\[') > 1 -- we don't need the attributes from the xml root node
and not startswith(x.key, '@xmlns') -- we don't need attributed data about xml namespaces
{% endset %}
{% set results = run_query(attribute_query) %}
{% if execute %}
{% set results_list = results.columns[0].values() %}
{% else %}
{% set results_list = [] %}
{% endif %}
{% for attribute in results_list %}
, get({{ node_col }}, '{{ attribute }}')::varchar(256) as attribute_{{ dbt_utils.slugify(attribute) | replace("@", "") }}
{% endfor %}
{% endmacro %}
Expected behavior
sqlfmt produces an error about an unterminated Jinja block and missing a endfor tag, but that tag does exist, and there doesn't appear to be any other incorrectly terminated items. The macro works without issue on Snowflake
Actual behavior
1 file had errors while formatting.
0 files left unchanged.
dbt/macros/get_unique_attributes.sql
sqlfmt encountered an error: Encountered unterminated Jinja block at position 720. Expected end tag: ({% endfor %})
Additional context
What is the output of sqlfmt --version?
Using VS Code extension, Trunk, which looks to be using [email protected]
The same error occurs when attempting the macro on the sqlfmt.com website.
The text was updated successfully, but these errors were encountered:
Thanks for the report! I'll investigate next week. I think the issue is that we hit get() without first parsing select, since that's inside of a set block. GET is also Snowflake DDL that we don't yet support, so we skip ahead to the end of the query and miss the ending jinja tag
* fix#326: do not match unsupported ddl followed by open parens
* refactor: parse unsupported DDL more granularly instead of with one big DATA token
* chore: update changelog
* fix: catch SqlfmtSegmentError and handle appropriately, do not use finally; fixes issue where we could drop lines entirely
* fix: stop using tail recursion for create_segments_from_lines
* chore: update primer refs
* refactor: simplify create_segments, add tests
Describe the bug
sqlfmt encountered an error: Encountered unterminated Jinja block at position 720. Expected end tag: ({% endfor %})
To Reproduce
Steps to reproduce the behavior. If this is a formatting issue, include the input code here.
Expected behavior
sqlfmt produces an error about an unterminated Jinja block and missing a endfor tag, but that tag does exist, and there doesn't appear to be any other incorrectly terminated items. The macro works without issue on Snowflake
Actual behavior
Additional context
What is the output of
sqlfmt --version
?Using VS Code extension, Trunk, which looks to be using [email protected]
The same error occurs when attempting the macro on the sqlfmt.com website.
The text was updated successfully, but these errors were encountered: