Skip to main content

Exit Codes

By default, SDF exits with the following status codes
  • 0 if no linter violations were found
  • 0 if linter completes successfully with any number of linter warnings
  • 64 if the linter fails for syntax reasons in any file
In CI/CD scenarios you may want to have the linter exit with a non-zero code if the linter finds any violations. For this, SDF supports the -w error flag which turns any lint warning into an error. In sdf yml, you configure this as follows::

Capitalization Keywords

SDF107

Inconsistent capitalization of keywords Example: sdf lint -w capitalization-keywords=upper Configuration:
workspace.sdf.yml
Anti-pattern Referencing keywords in inconsistent capitalization. All keywords should be either uppercase or lowercase, not both. Keywords are dialect-specific.
Best-practice

Capitalization Literals

SDF108

SDF109

Inconsistent capitalization of boolean/null literal Example: sdf lint -w capitalization-literals=upper Configuration:
workspace.sdf.yml
Anti-pattern Referencing literals in inconsistent capitalization. All references should be either uppercase or lowercase, not both.
Best-practice

Capitalization Types

SDF110

Inconsistent capitalization of datatypes. Example: sdf lint -w capitalization-types=upper Configuration:
workspace.sdf.yml
Anti-pattern Referencing datatypes in inconsistent capitalization. All references should be either uppercase or lowercase, not both.
Best-practice

Capitalization Functions

SDF106

Inconsistent capitalization of function names Example: sdf lint -w capitalization-functions=upper Configuration:
workspace.sdf.yml
Anti-pattern Referencing functions in inconsistent capitalization. All references should be either uppercase or lowercase, not both.
Best-practice

Convention Blocked Words

SDF124

Specify a list of names to block from being identifiers. Examples:
  • Blocking a single word: sdf lint -w convention-blocked-words=department
  • Blocking multiple words: sdf lint -w convention-blocked-words=word1,word2,...,wordn
Configuration:
workspace.sdf.yml

References Keywords

SDF125

Keywords should not be used as identifiers Example: sdf lint -w references-keywords Configuration:
workspace.sdf.yml
Anti-pattern Using built-in keywords or functions as identifiers. sss
Best-practice

References Special Chars

SDF117

Do not use special characters in identifiers Example:
  • Disallows $ character: sdf lint -w references-special-chars=$
  • Disallows $ and . characters: sdf lint -w references-special-chars=$.
Configuration:
workspace.sdf.yml
Anti-pattern Using special characters within identifiers when creating or aliasing objects.
Best-practice

References Quoting

SDF118

Unnecessary quoted identifier Example: sdf lint -w references-quoting Configuration:
workspace.sdf.yml
Anti-pattern Using quotes when naming a valid identifier, that is not a reserved keyword.
Best-practice Use unquoted identifiers where possible.

References Qualification

SDF116

Columns reference should specify source table or view in queries with more than one source. Example: sdf lint -w references-qualification Configuration:
workspace.sdf.yml
Anti-pattern Not specifying the source table or view when referencing columns in queries involving more than one source, thus creating ambiguity.
Best-practice

Ambiguous Column References

SDF105

Inconsistent column references in GROUP BY/ORDER BY clauses of both ordinal and non-ordinal Example: sdf lint -w ambiguous-column-references Configuration:
workspace.sdf.yml
Anti-pattern Using both explicit and implicit column references in the GROUP BY or ORDER BY clause. Reference should be consistent.
Best-practice Use unquoted identifiers where possible.

Structure Else Null

SDF119

Redundant ELSE NULL in a case when statement Example: sdf lint -w structure-else-null Configuration:
workspace.sdf.yml
Anti-pattern Stating ELSE NULL within a CASE WHEN statement.
Best-practice

Structure Simple Case

SDF120

CASE statement can be simplified Example: sdf lint -w structure-simple-case Configuration:
workspace.sdf.yml
Anti-pattern The following CASE statement are unnecessary and can be simplified:
Best-practice Use simpler SQL syntax:

Structure Unused Cte

SDF121

Query defines a CTE (common-table expression) but does not use it Example: sdf lint -w structure-unused-cte Configuration:
workspace.sdf.yml
Anti-pattern Defining CTEs that are not being used in the query (e.g., sub_2 in the example below).
Best-practice

Structure Nested Case

SDF122

Nested CASE statement in ELSE clause could be flattened. Example: sdf lint -w structure-nested-case Configuration:
workspace.sdf.yml
Anti-pattern Unnecessarily nesting CASE statements.
Best-practice

Structure Distinct

SDF123

DISTINCT used with parentheses Example: sdf lint -w structure-distinct Configuration:
workspace.sdf.yml
Anti-pattern Using DISTINCT with parentheses. In the example below, all columns are affected by the DISTINCT but can mistaken to think only column a is.
Best-practice

Structure Subquery

SDF113

Join/From clauses should not contain subqueries. Use CTEs instead Example: sdf lint -w structure-subquery=join Configuration:
workspace.sdf.yml
Anti-pattern Selecting from a subquery instead of defining the subquery in a CTE.
Best-practice

Structure Join Condition Order

SDF114

Join conditions column references should follow tables reference order Example: sdf lint -w structure_join_condition_order Configuration:
workspace.sdf.yml
Anti-pattern Referencing columns in join ON clause statement in a different order than the tables are referenced in the JOIN clause
Best-practice

Structure Column Order

SDF115

Select wildcards then simple targets before calculations and aggregates. Example: sdf lint -w structure-column-order Configuration:
workspace.sdf.yml
Anti-pattern Wildcard listed after single targets
Best-practice

Convention Terminator

SDF111

Statements should not end with a semi-colon. Multi-statements must be separated with a semi-colon but the final statement should NOT end with one. Example: sdf lint -w convention-terminator Configuration:
workspace.sdf.yml
Anti-pattern Ending the last statement with a semi-colon
Best-practice

Convention Comma

SDF104

Avoid trailing commas in lists. Configuration:
workspace.sdf.yml
Anti-pattern
Best-practice