Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a Jinja function to .sqlfluff config

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

like image 717
Squash Avatar asked Nov 27 '25 12:11

Squash


2 Answers

Add templater=dbt in your .sqlfluff config file.

More info here.

like image 134
Teghan Nightengale Avatar answered Dec 01 '25 17:12

Teghan Nightengale


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 %}
like image 34
Squash Avatar answered Dec 01 '25 17:12

Squash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!