sqlfluff /sqlfluff

A modular SQL linter and auto-formatter with support for multiple dialects and templated code.

★ 10,012⑂ 1,282👁 36▤ 144
PythonCreated 2018-11-02www.sqlfluff.com
10,012
stars
+0+1+70
1,282
forks
36
watchers
–
prs
–
issues
144
releases
–
discussions

README

!SQLFluff

 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.

 Table of Contents

1. Dialects Supported
2. Templates Supported
3. VS Code Extension
4. Getting Started
5. Documentation
6. Releases
7. SQLFluff on Slack
8. SQLFluff on Twitter
9. Contributing
10. Sponsors

 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
- Doris
- DuckDB
- Exasol
- FlinkSQL
- Greenplum
- Hive
- Impala
- MariaDB
- Materialize
- MySQL
- Oracle
- PostgreSQL (aka Postgres)
- Redshift
- Snowflake
- SOQL
- SparkSQL
- SQLite
- StarRocks
- 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 best 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:

- Github Repository
- Extension in VS Code marketplace

 Getting Started

To get started, install the package and run sqlfluff lint or sqlfluff fix.

shell
$ 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 | Ex

Snapshot: 2026-11-04T14:00:00Z · Data license Apache-2.0 · JSON