SDF Lint
SDF’s SQL Linter
Welcome to the future of SQL linting!
We have redefined SQL linting, setting a new standard for how we can help Data Engineers achieve readability, reliability, and performance in the data transformation layer. Our SQL Linter is build on top of SDF’s core engine to ensure unmatched accuracy, performance, and depth of rules compared with standard SQL linters.
100x Faster
SDF’s linter is 100x Faster than standard SQL Linters since it’s built with Rust and utilizes SDF’s sophisticated caching mechanism.
Accurate
Accurately detect issues in your SQL by relying on SDF’s core engine
Advanced rules
We provide advanced typing, optimization, and custom governance rules by leveraging to SDF’s one-of-a-kind SQL semantic understanding
- Semantic rules - derived from our semantic understanding of your SQL (e.g., prevent type cohesion)
- Performance rules - dialect-specific optimizations (e.g., prevent function application on indexed columns when filtering)
- SDF Checks - create custom lint rules on top of SDF’s information schema
Advanced rules rely on SDF’s compilation and will automatically execute sdf compile
as a
pre-requisite.
Linting Rule Types
Parameter | Description | Standard SQL Linter | SDF |
---|---|---|---|
Layout rules | SQL formatting rules | 🟢 | 🟢 |
Syntax rules | SQL syntax consistency and best practices rules | 🟡 | 🟢 |
Semantic rules | Logic and datatype related guardrails | 🔴 | 🟢 |
Performance rules | Performance enhancement recommendations | 🔴 | 🟢 |
Custom SDF Checks rules | Checks against SDF’s information schema | 🔴 | 🟢 |
Find Issues
- Use
sdf lint
to evaluate your SQL code against a set of linting rules - You can lint a subset of models by specifying targets for the command:
sdf lint [TARGET]
- Default linter configuration
Customize and Configure
- By default,
sdf lint
uses SDF’s recommended rules and configuration - To customize our linter rules according to your preferences, override the default
settings with a
linter-rules
configuration block in yourworkspace.sdf.yml
workspace:
...
defaults:
linter-rules: my_custom_linter
...
---
linter-rules:
name: my_custom_linter
syntax-rules:
flag-inconsistent-grouping: on
...
semantic-rules: # semantic-rules
disallow-implicit-conversions-in: [eq,in]
...
...
The linter config block will override the default configuration.
Default Rules
---
linter:
name: default_linter
semantic-rules:
disallow-implicit-conversions-in: [] # (off)
syntax-rules:
case-keyword: consistent
case-literal: consistent
case-type: consistent
disallow-subquery-in: [from, join]
disallow-these-chars-in-quoted-identifiers: ".#%{}\\<>*?/!'\":@+`|="
disallow-these-identifiers: []
flag-distinct-parenthesis: on
flag-inconsistent-qualified-column-reference: on
flag-inconsistent-ordinal-column-reference: on
flag-keywords-used-as-identifiers: []
flag-misordered-join-condition: on
flag-select-item-order: on
flag-trailing-semicolon-after-statements: on
flag-unnecessary-case: on
flag-unnecessary-else: on
flag-unnecessary-nested-case: on
flag-unnecessary-quoted-identifiers: on
flag-unqualified-multi-source-column-reference: on
flag-unused-cte: on
All other rules are turned off by default.
CI Integration
To learn how to integrate SDF into your CI/CD workflow, check out our
CI/CD guide. Once the integration is set up,
just add the sdf lint
command to the workflow configuration:
on:
pull_request:
...
- uses: sdf-labs/sdf-action@v0
with:
sdf_version: 'latest'
command: 'sdf lint'
snowflake_account_id: ${{ secrets.SNOWFLAKE_ACCOUNT_ID }}
snowflake_username: ${{ secrets.SNOWFLAKE_USERNAME }}
snowflake_password: ${{ secrets.SNOWFLAKE_PASSWORD }}
snowflake_role: ${{ secrets.SNOWFLAKE_ROLE }}
snowflake_warehouse: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
You can specify a target for the command to only run sdf lint
on a partial DAG
Rules Reference
For the full list of rules and configuration options, please visit our lint rules reference page