Linters
What is SQLFluff? An introduction to the open source SQL linter
SQLFluff is an open source SQL linter that checks SQL code against configurable style and syntax rules. It was designed with ELT applications in mind, works with Jinja templating and dbt, and automatically fixes most linting errors. It parses SQL directly, so it can catch syntax issues without access to a database.
- Tool
- SQLFluff
- Made by
- SQLFluff
- Official site
- sqlfluff.com
- Category
- Linters
Who makes SQLFluff
SQLFluff is an open source project that is community run and community funded. There is no corporate owner behind it: the work is carried by the people who use and contribute to it.
The official website, sqlfluff.com, is linked below.
Official website: sqlfluff.com
What SQLFluff is for
SQLFluff is for keeping SQL consistent and correct without relying on people to spot problems by eye. It reports issues automatically, so code reviews can focus on what a query does rather than how it is formatted.
It works by parsing your SQL. Because the parsing happens inside the tool, it can catch syntax issues without needing access to a database. That means checks can run on code alone, wherever the code lives.
The project was designed with ELT applications in mind. SQL in those workflows is often templated and spread across many files, which is why support for Jinja templating and dbt is part of the tool rather than an afterthought.
Who SQLFluff is for
The vendor describes the audience as teams wanting consistent SQL style, and as ELT and dbt users. If several people write SQL against the same project, a shared linter replaces style arguments in review with rules everyone can run locally.
Teams using dbt or Jinja templating are a natural fit, since SQLFluff understands those formats. Teams that use SQLMesh can also use SQLFluff, because a SQLMesh templater exists for it.
Notable capabilities
SQLFluff combines linting, automatic fixing and configuration in a Python package with a command-line interface. These are the capabilities that define it.
- Automatic fixes: it automatically fixes most linting errors, so many findings do not need manual edits.
- Templating support: it works with Jinja templating and dbt, and a SQLMesh templater exists for SQLFluff.
- Syntax checking without a database: it parses SQL to catch syntax issues without needing database access.
- Dialect and style flexibility: it supports a range of SQL dialects and style choices through configuration.
- Opinionated defaults: it ships with opinionated defaults plus flexible configuration options, so it is usable out of the box and adjustable later.
- Simple installation: it can be installed from PyPI using pip or another Python package manager.
- Command-line interface: the lint command takes a dialect option, so you tell it which SQL dialect to check against.
- Rust implementations: SQLFluff 4.0 began introducing Rust implementations of the lexer and parser.
How SQLFluff fits linters
Linters check source code against a set of rules for style and likely mistakes. SQLFluff applies that idea to SQL, a language whose formatting and dialect differences often go unchecked in projects that lint their application code carefully.
In Linthelm's wider niche of linters, static analysis and code quality, SQLFluff covers the data and analytics side. It inspects code without running it or connecting to a database, which is the defining trait of static analysis, and it enforces consistency, which is a core part of code quality.
Its configurability is what lets it fit different projects. Teams can start with the opinionated defaults and then adjust dialect and style choices to match the SQL they actually write.
Frequently asked questions
What is SQLFluff used for?
SQLFluff is used to lint SQL code for style and syntax issues. It reports problems automatically so code reviews can focus on function rather than form, and it automatically fixes most linting errors.
Does SQLFluff work with dbt and Jinja?
Yes. SQLFluff works with Jinja templating and dbt, and it was designed with ELT applications in mind. A SQLMesh templater also exists for it.
Does SQLFluff need a database connection?
No. SQLFluff parses SQL to catch syntax issues without needing database access.
How do I install SQLFluff?
Install it from PyPI using pip or another Python package manager. Its command-line interface has a lint command that takes a dialect option.
Who develops SQLFluff?
SQLFluff is an open source project that is community run and community funded.
Linthelm is independent and is not affiliated with SQLFluff. Product names belong to their owners. Features change; confirm details on the official website.