SQLFluff-templater-dbt is a plugin for SQLFluff, the SQL linter for humans, specifically designed to correctly parse and compile SQL projects using dbt (data build tool). It extends SQLFluff's capabilities to lint dbt models by leveraging dbt's templating engine. The project releases in conjunction with the main SQLFluff library, with version 4.1.0 being the latest as of March 2026. [2, 5, 13]
pip install sqlfluff sqlfluff-templater-dbt dbt-core dbt-snowflake # Replace dbt-snowflake with your adapterNo compatibility data collected yet for this library.
To use sqlfluff-templater-dbt, you must first install the package along with `sqlfluff`, `dbt-core`, and your specific `dbt` adapter. You then configure SQLFluff in a `.sqlfluff` file at your dbt project root, explicitly setting `templater = dbt` and specifying your SQL `dialect`. [1, 4, 12] It's also recommended to configure `project_dir` and `profiles_dir` within the `[sqlfluff:templater:dbt]` section and enable dbt built-ins in the `[sqlfluff:templater:jinja]` section. [1, 4, 9] An `.sqlfluffignore` file is crucial to prevent linting dbt compilation artifacts. [1, 12] Once configured, you can run `sqlfluff lint` or `sqlfluff fix` from your project's root.
Add `templater = dbt` under the `[sqlfluff]` section in your project's root `.sqlfluff` configuration file.
Always check the SQLFluff release notes and documentation for the supported `dbt-core` versions when upgrading either library. For `dbt` Fusion, using the standalone `dbt-core` engine templater locally is a current workaround. [14]
Consider the trade-off between speed and accuracy. For CI/CD contexts where compilation accuracy is critical, the `dbt` templater is preferred. For local IDE or git hook usage where speed is paramount, the `jinja` templater might be more suitable, potentially with mock macros. [1]
If encountering parsing issues with deep queries, consider increasing `max_parse_depth` in your `.sqlfluff` configuration file under the `[sqlfluff]` section: `max_parse_depth = 500` (or a suitable higher value).
Ensure your environment uses Python 3.9 or a later version. Upgrade your Python installation if necessary.
To surface these errors and ensure complete template rendering, set `dbt_skip_compilation_error = False` in the `[sqlfluff:templater:dbt]` section of your `.sqlfluff` configuration file.
Ensure the plugin is installed with `pip install sqlfluff-templater-dbt` and verify that `templater = dbt` is correctly set in your SQLFluff configuration file (e.g., `.sqlfluff` or `pyproject.toml`) under the `[sqlfluff]` section.
Add `dbt_project_dir = <your/dbt/project/path>` to the `[sqlfluff:templater:dbt]` section of your `.sqlfluff` configuration file, or specify it via the command line: `sqlfluff lint --templater dbt --dbt-project-dir <your/dbt/project/path>`.
Ensure your `dbt_profiles_dir` is correctly set in your SQLFluff configuration (`[sqlfluff:templater:dbt]`) to point to the directory containing `profiles.yml`, and that the `profiles.yml` file contains the required profile for your dbt project.
Debug the dbt compilation error directly by running `dbt compile <model_name>` on the affected model; ensure all macros are defined, variables are passed, and Jinja syntax is valid within your dbt project.