Overview
SDF contains an integrated high performance SQL linter and formatter. Linting and formatting are core competencies of code-hygiene designed ensure code is consistent across your organization, simplify readability, code reviews, and promote standardization. SDF’s SQL Linter has 4 crucial characteristics.- It is incredibly high performance, outperforming SQLFluff by well over 100X in most scenarios.
- It has a high degree of overlap with SQL Fluff to ensure easy migration for existing SQLFLuff users.
- It is out-of-the-box compatible with all SDF Jinja and configuration
- Unless otherwise configured, every SDF workspace has Default Rules.
- All files listed in your
includespaths will be linted. - Run
sdf lintto lint sql files - Run
sdf lint path/to/file.sqlto lint a subset of SQL files - Run
sdf lint --fixto fix issues where possible - Run
sdf formatto format sql files
sdf-args block in your sdf workspace file. These
defaults are command line flags that are implicitly added to each invocation of sdf lint.
workspace.sdf.yml
Dialect Compatibility
SQL linting is dialect specific. Currently, SDF Lint is only available for the Snowflake and BigQuery SQL dialects. Other dialects are coming soon.| Dialect | Availability |
|---|---|
| Snowflake | 🟢 |
| BigQuery | 🟢 |
| Redshift | 🟡 |
| Trino | 🔴 |
| SparkSQL | 🔴 |
Default Rules
SDF has a set of default lint rules. Default rules designed to provide a simple configuration for most data teams. All defaults can be auto-fixed or overwritten through manual configuration. SDF’s lint defaults are equivalent to the followingsdf-args configuration. If no overrides for sdf-args are specified,
any invocation of sdf lint will use the default lint defaults. These defaults are as below:
workspace.sdf.yml
All other rules are turned off by default.
All default lint rules can be automatically fixed with
sdf lint --fixAutomatically Fix Issues
- Use
sdf lint --fixto automatically resolve linting issues where possible - For issues that can’t be automatically fixed, SDF will provide error reports
fix.sql
Ignore Warnings
If you would like to ignore a lint warning for whatever reason, add the inline comment-- noqa to your query. This will prevent that line from being
evaluated by the linter, for all rules.
nofix.sql
Customize and Configure
- By default,
sdf lintuses SDF’s recommended rules and configuration - To customize linter rules according to your preferences, override the default settings with a
sdf-argsblock in yourworkspace.sdf.yml
The
sdf-args: config block in a workspace file will override the default configuration.Default Rules
Per default, every SDF project has the following linter configuration turned on implicitly. If you specify your own YML linter configuration, you will turn off the default rules and need to specify all linting rules yourself.Rules Reference
For the full list of rules and configuration options, please visit our lint rules reference page| Type | Configuration | SDF Err | SQLFluff Err | Auto-Fix | Default |
|---|---|---|---|---|---|
| Syntax | capitalization_keywords | SDF107 | L010 | ✅ | consistent |
| Syntax | capitalization-literal | SDF108, SDF109 | L040 | ✅ | consistent |
| Syntax | capitalization-type | SDF110 | L063 | ✅ | consistent |
| Syntax | capitalization-function | SDF106 | L030 | ✅ | consistent |
| Syntax | convention-blocked-words | SDF124 | L029 | ❌ | [] |
| Syntax | references-keywords | SDF125 | L029 | ❌ | [] |
| Syntax | references-special-chars | SDF117 | L057 | ❌ | "" |
| Syntax | references-quoting | SDF118 | L059 | ✅ | on |
| Syntax | references-consistent | SDF112 | L028 | ❌ | off |
| Syntax | references-qualification | SDF116 | L027 | ❌ | off |
| Syntax | ambiguous-column-references | SDF105 | L054 | ❌ | off |
| Syntax | structure-else-null | SDF119 | L035 | ✅ | on |
| Syntax | structure-simple-case | SDF120 | L043 | ❌ | off |
| Syntax | structure-unused-cte | SDF121 | L045 | ✅ | only |
| Syntax | structure-nested-case | SDF122 | L058 | ❌ | off |
| Syntax | structure-distinct | SDF123 | L015 | ✅ | on |
| Syntax | structure-join-condition-order | SDF114 | ST09 | ❌ | off |
| Syntax | structure-column-order | SDF115 | L034 | ✅ | off |
| Syntax | convention-terminator | SDF111 | L052 | ✅ | on |
| Syntax | convention-comma | SDF104 | N/A | ✅ | on |