# SQLFluff

Paradime provides native integration with SQLFluff, enabling automatic linting and formatting of SQL files in your dbt™ project directly from the IDE. This integration helps maintain consistent code style and catch potential SQL issues early, with built-in support for dbt™ and Jinja templating.

### Integration Features

* One-click SQL linting through the Lint button
* Built-in dbt™ templating support
* Native IDE integration
* Customizable linting rules
* Auto-fix capabilities for common issues

***

### Using the Integration

1. Open a `.sql` file in your editor
2. Click the **Lint** button in the [Command Panel](/app-help/documentation/code-ide/command-panel.md)
3. Review the changes made in [Git Lite](/app-help/documentation/code-ide/left-panel/git-lite.md)
   * Syntax errors
   * Style violations
   * Formatting suggestions
4. If satisfied with Lint updates, [Commit and Push](/app-help/documentation/code-ide/left-panel/git-lite.md#commit-and-push-your-changes) your changes to your remote branch.&#x20;

<figure><img src="/files/PM0bc411j3X79Jj5smhA" alt=""><figcaption><p>Using the Lint button for .sql file using SQLfluff</p></figcaption></figure>

### Configuration

Configure SQLFluff by creating a `.sqlfluff` file in your dbt™ project root directory:

1. Create a `.sqlfluff` file in your dbt™ project root directory (same location as your `dbt_project.yml`)
2. Add your configuration:

{% code title=".sqlfluff example file" %}

```yaml
[sqlfluff]
# Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
dialect = snowflake
templater = dbt

# Comma separated list of rules to exclude, or None
# See https://docs.sqlfluff.com/en/stable/configuration.html#enabling-and-disabling-rules
# AM04 (ambiguous.column_count) and ST06 (structure.column_order) are
# two of the more controversial rules included to illustrate usage.
exclude_rules = ambiguous.column_count, structure.column_order

# The standard max_line_length is 80 in line with the convention of
# other tools and several style guides. Many projects however prefer
# something a little longer.
# Set to zero or negative to disable checks.
max_line_length = 120

# If using the dbt templater, we recommend setting the project dir.
[sqlfluff:templater:dbt]
project_dir = ./

[sqlfluff:indentation]
# While implicit indents are not enabled by default. Many of the
# SQLFluff maintainers do use them in their projects.
allow_implicit_indents = true

# The default configuration for aliasing rules is "consistent"
# which will auto-detect the setting from the rest of the file. This
# is less desirable in a new project and you may find this (slightly
# more strict) setting more useful.
[sqlfluff:rules:aliasing.table]
aliasing = explicit

[sqlfluff:rules:aliasing.column]
aliasing = explicit

[sqlfluff:rules:aliasing.length]
min_alias_length = 3

# The default configuration for capitalization rules is "consistent"
# which will auto-detect the setting from the rest of the file. This
# is less desirable in a new project and you may find this (slightly
# more strict) setting more useful.
# Typically we find users rely on syntax highlighting rather than
# capitalization to distinguish between keywords and identifiers.
# Clearly, if your organization has already settled on uppercase
# formatting for any of these syntax elements then set them to "upper".
# See https://stackoverflow.com/questions/608196/why-should-i-capitalize-my-sql-keywords-is-there-a-good-reason
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.identifiers]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = lower

[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = lower
```

{% endcode %}

{% hint style="info" %}
Visit [SQLfluff documentation](https://docs.sqlfluff.com/en/stable/configuration.html) for a complete list of configuration options.
{% endhint %}

{% @arcade/embed flowId="M3tkMiQ8rJHKsjustE4s" url="<https://app.arcade.software/share/M3tkMiQ8rJHKsjustE4s>" %}

{% hint style="info" %}
Want to automate SQLfluff linting? Learn how to set up [SQLfluff pre-commit hooks](/app-help/documentation/integrations/code-ide/pre-commit/sqlfluff-hooks.md) to automatically lint SQL files before each commit.
{% endhint %}

***

### Common Rules

SQLFluff enforces several key formatting rules:

* Consistent keyword capitalization
* Required table aliasing
* Maximum line length
* Proper indentation
* Column ordering

### dbt™ Support

The integration automatically handles dbt™-specific features:

* Jinja templating
* ref() and source() functions
* dbt™ macros
* Project configurations


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paradime.io/app-help/documentation/integrations/code-ide/sql-fluff.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
