else-null
What it does
Section titled “What it does”Reports a CASE branch ELSE NULL.
Why it matters
Section titled “Why it matters”A CASE that does not match returns NULL without an ELSE, so the branch says what is already the case.
To fix, remove the ELSE NULL.
Example
Section titled “Example”...select a from t left join u on t.a = u.a;select case when a then 1 else null end, case when a then 1 else 2 end from t;...Configuration
Section titled “Configuration”sql: lint: rules: else-null: warn # off, warn (default), errorEnabled by the presets: sql/sqlfluff.
Suppress one line with sudsy-disable-next-line else-null in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| sqlfluff | ST01 |
full |