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.
- 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
- 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!