SQLFluff is a dialect-flexible and configurable SQL linter. Designed
with ELT applications in mind, SQLFluff also works with Jinja templating
and dbt. SQLFluff will auto-fix most linting errors, allowing you to focus
your time on what matters.
Although SQL is reasonably consistent in its implementations, there are several
different dialects available with variations of syntax and grammar. SQLFluff
currently supports the following SQL dialects (though perhaps not in full):
ANSI SQL - this is the base version and on occasion may not strictly follow
the ANSI/ISO SQL definition
We aim to make it easy to expand on the support of these dialects and also
add other, currently unsupported, dialects. Please raise issues
(or upvote any existing issues) to let us know of demand for missing support.
Pull requests from those that know the missing syntax or dialects are especially
welcomed and are the question way for you to get support added. We are happy
to work with any potential contributors on this to help them add this support.
Please raise an issue first for any large feature change to ensure it is a good
fit for this project before spending time on this work.
To get started, install the package and run collate-sqlfluff lint or collate-sqlfluff fix.
$ pip install collate-sqlfluff
$ echo " SELECT a + b FROM tbl; " > test.sql
$ collate-sqlfluff lint test.sql --dialect ansi
== [test.sql] FAIL
L: 1 | P: 1 | LT01 | Expected only single space before 'SELECT' keyword.
| Found ' '. [layout.spacing]
L: 1 | P: 1 | LT02 | First line should not be indented.
| [layout.indent]
L: 1 | P: 1 | LT13 | Files must not begin with newlines or whitespace.
| [layout.start_of_file]
L: 1 | P: 11 | LT01 | Expected only single space before binary operator '+'.
| Found ' '. [layout.spacing]
L: 1 | P: 14 | LT01 | Expected only single space before naked identifier.
| Found ' '. [layout.spacing]
L: 1 | P: 27 | LT01 | Unnecessary trailing whitespace at end of file.
| [layout.spacing]
L: 1 | P: 27 | LT12 | Files must end with a single trailing newline.
| [layout.end_of_file]
All Finished 📜 🎉!
For full documentation visit docs.sqlfluff.com.
This documentation is generated from this repository so please raise
issues or pull requests
for any additions, corrections, or clarifications.
Releases
SQLFluff adheres to Semantic Versioning,
so breaking changes should be restricted to major versions releases. Some
elements (such as the python API) are in a less stable state and may see more
significant changes more often. For details on breaking changes and how
to migrate between versions, see our
release notes. See the
changelog for more details. If you would like to join in, please
consider contributing.
New releases are made monthly. For more information, visit
Releases.
SQLFluff on Slack
We have a fast-growing community
on Slack,
come and join us!