0

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

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96
Squash
  • 27
  • 1
  • 5

2 Answers2

3

Add templater=dbt in your .sqlfluff config file.

More info here.

0

I have managed to figure out how to add run_query:

run_query = {% macro run_query(query) %}'query'{% endmacro %}

But I am still unsure on how to add execute to the .sqlfluff config. Figured it!

execute = {% macro execute() %}True{% endmacro %}
Squash
  • 27
  • 1
  • 5
  • Hi @Squash, can you please explain in more detail to me how you added those things to `.sqlfluff` to solve similar issues like yours (in my case, it is `Unrecoverable failure in Jinja templating: 'adapter' is undefined.`). Thank you. – natterstefan May 17 '23 at 21:28