It turns out that you can add Jinja syntax support for dbt model files (.sql) and yaml files in PyCharm Professional Edition or other paid JetBrains products that have multi-language support (Sorry DataGrip users). Here’s how to do it.
Disclaimers
Unfortunately this is not available in the Community Edition of PyCharm.
There is currently a bug in JetBrains IDE that shows a valid SQL with Jinja as having syntax errors if a SQL Dialect is selected to something other than “Generic SQL” (e.g Snowflake) Link to ticket. The workaround is to either set the global or project SQL Dialect setting under Languages & Frameworks to “Generic SQL”.
This is not possible to do in DataGrip
Steps
Preferences > Languages and Frameworks > Template Languages.
Select “Jinja2” for the Template Language dropdown at the top,
Click on the “+” icon to add SQL (and YAML) to the list. Hit Apply or OK and you are done!
I just recently rolled out a dbt workstation environment to a team of 15 and I have been asked if this sort of configuration is possible using VSCode. The VSCode python extension behaves properly and locates the dbt virtualenv, but I ly by manually initiating the extension. Since it is only set to auto initialize on .py files…not .sql
I was trying to follow your steps but whenever I setup jinja2 it affects my keyboard and i am not able to type anything anymore in my IDE (Pycharm pro), anyone experienced something similar ?
I am experiencing the same thing in PyCharm. I am able to set up the .sql files to have templates but when I specify the template language as Jinja, all my keyboard inputs are eaten up.