SQLFluff

Learn how Paradime integrates with SQLFluff to automatically lint and format your dbt™ SQL files.

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

  3. Review the changes made in Git Lite

    • Syntax errors

    • Style violations

    • Formatting suggestions

  4. If satisfied with Lint updates, Commit and Push your changes to your remote branch.

Using the Lint button for .sql file using SQLfluff

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:

.sqlfluff example file
[sqlfluff]
dialect = snowflake  # Update based on your warehouse

[sqlfluff]
# Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
dialect = bigquery # Update based on your warehouse
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

Visit SQLfluff documentation for a complete list of configuration options.

Want to automate SQLfluff linting? Learn how to set up SQLfluff pre-commit hooks to automatically lint SQL files before each commit.


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

Last updated

Was this helpful?