Reputation: 87
I'm using the jinja functions run_query and execute. https://docs.getdbt.com/reference/dbt-jinja-functions/run_query
But when sqlfluff lint I get the following error: Undefined jinja template variable: 'run_query'
I'm trying to add it to the .sqlfluff config but there doesn't seem to be any guidance anywhere on how to add this to the config file.
Any help would be greatly appreciated! Thanks
Upvotes: 1
Views: 10409
Reputation: 87
I have managed to figure out how to add run_query
!
I was also unsure on how to add execute
to the .sqlfluff
config, but I figured it out!
[sqlfluff:templater:jinja:macros]
run_query = {% macro run_query(query) %}'query'{% endmacro %}
execute = {% macro execute() %}True{% endmacro %}
Upvotes: 1
Reputation: 7952
If using the default jinja
templater:
In addition to macros specified in the config file, macros can also be loaded from files or folders. This is specified in the config file:
[sqlfluff:templater:jinja] load_macros_from_path = my_macros
See https://docs.sqlfluff.com/en/stable/configuration.html#jinja-macro-templating-from-file
Upvotes: 1
Reputation: 528
Add templater=dbt
in your .sqlfluff
config file.
More info here.
Upvotes: 5