is currently only available in our preview release. Preview features are not recommended for production use. For more information on how to install or update to the Preview release channel, see here.

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.
  1. It is incredibly high performance, outperforming SQLFluff by well over 100X in most scenarios.
  2. It has a high degree of overlap with SQL Fluff to ensure easy migration for existing SQLFLuff users.
  3. It is out-of-the-box compatible with all SDF Jinja and configuration
SDF’s auto-formatter works in conjunction with the linter to empower teams to write more unified SQL code. Using the linter is easy.
  • Unless otherwise configured, every SDF workspace has Default Rules.
  • All files listed in your includes paths will be linted.
  • Run sdf lint to lint sql files
  • Run sdf lint path/to/file.sql to lint a subset of SQL files
  • Run sdf lint --fix to fix issues where possible
  • Run sdf format to format sql files
To create a global linter configuration for your workspace, you can use the 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
sdf-args
   lint: >
     -w <lint-rule>=<option>
     ...

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.
DialectAvailability
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 following sdf-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
sdf-args
   lint: >
      -w capitalization-keywords=consistent 
      -w capitalization-literals=consistent 
      -w capitalization-types=consistent 
      -w capitalization-functions=consistent 
      -w refernces-quoting
      -w structure-else-null
      -w structure-unused-cte
      -w structure-distinct
      -w structure-column-order
      -w convention-terminator
All other rules are turned off by default.
All default lint rules can be automatically fixed with sdf lint --fix

Automatically Fix Issues

  • Use sdf lint --fix to automatically resolve linting issues where possible
  • For issues that can’t be automatically fixed, SDF will provide error reports
fix.sql
select * FROM test

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
SeLeCt * from test --noqa

Customize and Configure

  • By default, sdf lint uses SDF’s recommended rules and configuration
  • To customize linter rules according to your preferences, override the default settings with a sdf-args block in your workspace.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
TypeConfigurationSDF ErrSQLFluff ErrAuto-FixDefault
Syntaxcapitalization_keywordsSDF107L010consistent
Syntaxcapitalization-literalSDF108, SDF109L040consistent
Syntaxcapitalization-typeSDF110L063consistent
Syntaxcapitalization-functionSDF106L030consistent
Syntaxconvention-blocked-wordsSDF124L029[]
Syntaxreferences-keywordsSDF125L029[]
Syntaxreferences-special-charsSDF117L057""
Syntaxreferences-quotingSDF118L059on
Syntaxreferences-consistentSDF112L028off
Syntaxreferences-qualificationSDF116L027off
Syntaxambiguous-column-referencesSDF105L054off
Syntaxstructure-else-nullSDF119L035on
Syntaxstructure-simple-caseSDF120L043off
Syntaxstructure-unused-cteSDF121L045only
Syntaxstructure-nested-caseSDF122L058off
Syntaxstructure-distinctSDF123L015on
Syntaxstructure-join-condition-orderSDF114ST09off
Syntaxstructure-column-orderSDF115L034off
Syntaxconvention-terminatorSDF111L052on
Syntaxconvention-commaSDF104N/Aon