Paradime Help Docs
Ask or search…
K

SQL fluff

SQLFluff is a dialect-flexible and configurable SQL linter it works with Jinja templating and dbt™️. SQLFluff will auto-fix most linting errors, allowing you to focus your time on what matters.
Paradime provides an integration out of the box for you to run SQLFluff in your dbt™️ project.

Configuration

Create the .sqlfluff configuration file

To get started simply you will need to create a file called .sqlfluff in your dbt™️ root directory (this is in the same directory where your dbt_project.yml lives.

Set your configuration file by adding supported rules

Now you will need to add your own configuration to decide which rules to enforce when running SQLFluff in the Paradime terminal.
You can copy and paste the below template to get started with some simple rules. Make sure to update line 4 with the appropriate sql dialect based on your data warehouse provider.
.sqlfluff
1
[sqlfluff]
2
# Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
3
# Or run 'sqlfluff dialects in the paradime terminal'
4
dialect = snowflake #<--- update the dialect based on your connected data warehouse
5
templater = dbt
6
7
[sqlfluff:templater:dbt]
8
project_dir = ./
9
10
# Comma separated list of rules to exclude, or None
11
# See https://docs.sqlfluff.com/en/stable/configuration.html#enabling-and-disabling-rules
12
# AM04 (ambiguous.column_count) and ST06 (structure.column_order) are
13
# two of the more controversial rules included to illustrate usage.
14
exclude_rules = ambiguous.column_count, structure.column_order
15
16
# The standard max_line_length is 80 in line with the convention of
17
# other tools and several style guides. Many projects however prefer
18
# something a little longer.
19
# Set to zero or negative to disable checks.
20
max_line_length = 120
21
22
# If using the dbt templater, we recommend setting the project dir.
23
24
25
[sqlfluff:indentation]
26
# While implicit indents are not enabled by default. Many of the
27
# SQLFluff maintainers do use them in their projects.
28
allow_implicit_indents = true
29
30
# The default configuration for aliasing rules is "consistent"
31
# which will auto-detect the setting from the rest of the file. This
32
# is less desirable in a new project and you may find this (slightly
33
# more strict) setting more useful.
34
[sqlfluff:rules:aliasing.table]
35
aliasing = explicit
36
[sqlfluff:rules:aliasing.column]
37
aliasing = explicit
38
[sqlfluff:rules:aliasing.length]
39
min_alias_length = 3
40
41
# The default configuration for capitalization rules is "consistent"
42
# which will auto-detect the setting from the rest of the file. This
43
# is less desirable in a new project and you may find this (slightly
44
# more strict) setting more useful.
45
# Typically we find users rely on syntax highlighting rather than
46
# capitalization to distinguish between keywords and identifiers.
47
# Clearly, if your organization has already settled on uppercase
48
# formatting for any of these syntax elements then set them to "upper".
49
# See https://stackoverflow.com/questions/608196/why-should-i-capitalize-my-sql-keywords-is-there-a-good-reason
50
[sqlfluff:rules:capitalisation.keywords]
51
capitalisation_policy = lower
52
[sqlfluff:rules:capitalisation.identifiers]
53
capitalisation_policy = lower
54
[sqlfluff:rules:capitalisation.functions]
55
extended_capitalisation_policy = lower
56
[sqlfluff:rules:capitalisation.literals]
57
capitalisation_policy = lower
58
[sqlfluff:rules:capitalisation.types]
59
extended_capitalisation_policy = lower
You can check all the rules to help you manage code readability at the link below.

Running SQLFluff

SQLFluff provides a CLI to execute commands and lint your sql files in your dbt™️ project.
With Paradime you can execute SQLFluff with one click using the Prettify button in the terminal toolbar.
Simply open the file you want to lint and click on the Prettify button.