# 📜 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 releases:

- 1.0.x: First stable release, no major changes to take advantage of a point of relative stability.

- 2.0.x: Recode of rules, whitespace fixing consolidation, `sqlfluff format` and removal of support for dbt versions pre 1.1. Note, that this release brings with it some breaking changes to rule coding and configuration, see Upgrading from 1.x to 2.0.

- 3.0.x: `sqlfluff fix` now defaults to not asking for confirmation and the –force option was removed. Richer information returned by the `sqlfluff lint` command (although in a different structure to previous versions). See Upgrading to 3.x.

For more detail on other releases, see our Release Notes.

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 | 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 📜 🎉!

## Contents

Documentation for SQLFluff:

- Getting Started
  - Installing Python
  - Installing SQLFluff
  - Basic Usage
  - Custom Usage
  - Going further
- Why SQLFluff?
  - Quality assurance
  - Modularity
  - Vision for SQLFluff
- Guides & How-tos
  - Setting up SQLFluff
    - Rolling out SQLFluff with a new team
    - Developing Custom Rules
  - Troubleshooting SQLFluff
    - How to Troubleshoot SQLFluff
  - Contributing to SQLFluff
    - Architecture
    - How to use Git
    - Contributing dialect changes
    - Developing Rules
    - Developing Plugins
    - Documentation Contributions
- Configuration
  - Setting Configuration
    - Configuration Files
    - In-File Configuration Directives
  - Rule Configuration
    - Enabling and Disabling Rules
    - Downgrading rules to warnings
    - Layout & Spacing Configuration
  - Layout & Whitespace Configuration
    - Spacing
    - Templating and alignment coordinate space
    - Advanced: coordinate space override
    - Line Breaks
    - Indentation
    - Configuring Layout
  - Templating Configuration
    - Jinja templater
    - Placeholder templater
    - Python templater
    - `dbt` templater
    - Generic Variable Templating
  - Ignoring Errors & Files
    - Ignoring individual lines
    - Ignoring line ranges
    - `.sqlfluffignore`
    - Ignoring types of errors
  - Default Configuration
- Production Usage & Security
  - Security Considerations
  - Using SQLFluff directly as a CLI application
  - Using SQLFluff on changes using `diff-quality`
    - Adding `diff-quality` to your builds
  - Using `pre-commit`
    - Ignoring files while using `pre-commit`
  - Using GitHub Actions to Annotate PRs
- Reference
  - Dialects Reference
    - ANSI
    - AWS Athena
    - Google BigQuery
    - ClickHouse
    - Databricks
    - IBM Db2
    - Apache Doris
    - DuckDB
    - Exasol
    - Apache Flink SQL
    - Greenplum
    - Apache Hive
    - Apache Impala
    - MariaDB
    - Materialize
    - MySQL
    - Oracle
    - PostgreSQL
    - AWS Redshift
    - Snowflake
    - Salesforce Object Query Language (SOQL)
    - Apache Spark SQL
    - SQLite
    - StarRocks
    - Teradata
    - Trino
    - Microsoft T-SQL
    - Vertica
  - Rules Reference
    - Core Rules
    - Rule Index
    - Aliasing bundle
    - Ambiguous bundle
    - Capitalisation bundle
    - Convention bundle
    - Jinja bundle
    - Layout bundle
    - References bundle
    - Structure bundle
    - TSQL bundle
  - CLI Reference
    - sqlfluff
  - Python API
    - Simple API commands
    - Advanced API usage
  - Internal API
    - `sqlfluff.core.config`: Configuration & `FluffConfig`
    - `sqlfluff.core.rules.base`: Base Rule Classes
    - `sqlfluff.utils.functional`: Functional Traversal API
    - `sqlfluff.utils.reflow`: Whitespace Reflow API
  - Release Notes
    - Upgrading to 3.x
    - Upgrading to 2.3
    - Upgrading to 2.2
    - Upgrading from 1.x to 2.0
    - Upgrading to 1.4
    - Upgrading to 1.3
    - Upgrading to 1.2
    - Upgrades pre 1.0
- SQLFluff in the Wild
- SQLFluff Slack
- SQLFluff on Twitter

# Indices and tables

- Index

- Module Index

- Search Page