📜 The SQL Linter for Humans¶
Bored of not having a good SQL linter that works with whichever dialect you’re working with? Fluff is an extensible and modular linter designed to help you write good SQL and catch errors and bad SQL before it hits your database.
Notable changes:
0.1.x involved a major re-write of the parser, completely changing the behaviour of the tool with respect to complex parsing.
0.2.x added templating support and a big restructure of rules and changed how users might interact with SQLFluff on templated code.
0.3.x drops support for python 2.7 and 3.4, and also reworks the handling of indentation linting in a potentially not backward compatible way.
0.4.x dropped python 3.5, added the dbt templater, source mapping and also introduced the python API.
0.5.x introduced some breaking changes to the API.
0.6.x introduced parallel processing, which necessitated a big re-write of several innards.
0.7.x extracted the dbt templater to a separate plugin and removed the
exasol_fs
dialect (now merged in with the mainexasol
).0.8.x an improvement to the performance of the parser, a rebuild of the Jinja Templater, and a progress bar for the CLI.
0.9.x refinement of the Simple API, dbt 1.0.0 compatibility, and the official SQLFluff Docker image.
0.10.x removed support for older dbt versions < 0.20 and stopped
fix
attempting to fix unparsable SQL.0.11.x rule L030 changed to use
extended_capitalisation_policy
.0.12.x dialect is now mandatory, the
spark3
dialect was renamed tosparksql
and datatype capitalisation was extracted from L010 to it’s own rule L063.0.13.x new rule for quoted literals, option to remove hanging indents in rule L003, and introduction of
ignore_words_regex
.1.0.0 first stable release, no major changes to take advantage of a point of relative stability.
Want to see where and how people are using SQLFluff in their projects? Head over to SQLFluff in the Wild for inspiration.
Getting Started¶
To get started just install the package, make a sql file and then run SQLFluff and point it at the file. For more details or if you don’t have python or pip already installed see Getting Started.
$ pip install sqlfluff
$ echo " SELECT a + b FROM tbl; " > test.sql
$ sqlfluff lint test.sql --dialect ansi
== [test.sql] FAIL
L: 1 | P: 1 | L050 | Files must not begin with newlines or whitespace.
L: 1 | P: 3 | L003 | First line has unexpected indent
L: 1 | P: 11 | L039 | Unnecessary whitespace found.
L: 1 | P: 14 | L039 | Unnecessary whitespace found.
L: 1 | P: 27 | L001 | Unnecessary trailing whitespace.
Contents¶
Documentation for SQLFluff:
- Getting Started
- SQL in the Wild
- Vision for SQLFluff
- Rolling out SQLFluff with a new team
- Let’s talk about indentation
- Rules Reference
- Core Rules
- Specific Rules
Rule_L001
Rule_L002
Rule_L003
Rule_L004
Rule_L005
Rule_L006
Rule_L007
Rule_L008
Rule_L009
Rule_L010
Rule_L011
Rule_L012
Rule_L013
Rule_L014
Rule_L015
Rule_L016
Rule_L017
Rule_L018
Rule_L019
Rule_L020
Rule_L021
Rule_L022
Rule_L023
Rule_L024
Rule_L025
Rule_L026
Rule_L027
Rule_L028
Rule_L029
Rule_L030
Rule_L031
Rule_L032
Rule_L033
Rule_L034
Rule_L035
Rule_L036
Rule_L037
Rule_L038
Rule_L039
Rule_L040
Rule_L041
Rule_L042
Rule_L043
Rule_L044
Rule_L045
Rule_L046
Rule_L047
Rule_L048
Rule_L049
Rule_L050
Rule_L051
Rule_L052
Rule_L053
Rule_L054
Rule_L055
Rule_L056
Rule_L057
Rule_L058
Rule_L059
Rule_L060
Rule_L061
Rule_L062
Rule_L063
Rule_L064
Rule_L065
Rule_L066
- Inline Ignoring Errors
- Dialects Reference
- Production Usage
- Configuration
- Architecture
- CLI Reference
- API Reference
- Developing Rules
- Developing Plugins
- SQLFluff in the Wild
- SQLFluff Slack
- SQLFluff on Twitter