The SQL Linter for Humans
Project description
The SQL Linter for Humans
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.
Dialects Supported
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
- Athena
- BigQuery
- ClickHouse
- Databricks (note: this extends the
sparksql
dialect with Unity Catalog syntax). - Db2
- DuckDB
- Exasol
- Greenplum
- Hive
- Materialize
- MySQL
- Oracle
- PostgreSQL (aka Postgres)
- Redshift
- Snowflake
- SOQL
- SparkSQL
- SQLite
- Teradata
- Transact-SQL (aka T-SQL)
- Trino
- Vertica
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.
Templates Supported
SQL itself does not lend itself well to modularity, so to introduce some flexibility and reusability it is often templated as discussed more in our modularity documentation.
SQLFluff supports the following templates:
- Jinja (aka Jinja2)
- SQL placeholders (e.g. SQLAlchemy parameters)
- Python format strings
- dbt (requires plugin)
Again, please raise issues if you wish to support more templating languages/syntaxes.
VS Code Extension
We also have a VS Code extension:
Getting Started
To get started, install the package and run sqlfluff lint
or sqlfluff fix
.
$ pip install sqlfluff
$ echo " SELECT a + b FROM tbl; " > test.sql
$ 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 📜 🎉!
Alternatively, you can use the Official SQLFluff Docker Image or have a play using SQLFluff online.
For full CLI usage and rules reference, see the SQLFluff docs.
Documentation
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!
SQLFluff on Twitter
Follow us on Twitter @SQLFluff for announcements and other related posts.
Contributing
We are grateful to all our contributors. There is a lot to do in this project, and we are just getting started.
If you want to understand more about the architecture of SQLFluff, you can find more here.
If you would like to contribute, check out the open issues on GitHub. You can also see the guide to contributing.
Sponsors
The turnkey analytics stack, find out more at Datacoves.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sqlfluff-3.2.5.tar.gz
.
File metadata
- Download URL: sqlfluff-3.2.5.tar.gz
- Upload date:
- Size: 831.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39822db2c6ad7dac9f6e43d36a3d086c503c051b09665d14a5bdf644770f6ef6 |
|
MD5 | 84243037b9bd2816900b10930d7d0797 |
|
BLAKE2b-256 | 33319ad9e98fc8d7bfd739204b0ee20f81840332754abe6f80ed53bb40875764 |
File details
Details for the file sqlfluff-3.2.5-py3-none-any.whl
.
File metadata
- Download URL: sqlfluff-3.2.5-py3-none-any.whl
- Upload date:
- Size: 836.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae9ff821986b5b0dd1ea858392db7f0eb80343c2cdeee7900fa031f581e04643 |
|
MD5 | 625156088774a91223a190dd11412936 |
|
BLAKE2b-256 | b146c748afebe5978abc90e8af20c17fb70fca237e8cbc5da1ed448208e51881 |