unused-cte
What it does
Section titled “What it does”Reports a common table expression that nothing in the WITH statement refers to.
Why it matters
Section titled “Why it matters”The expression is defined and never used, so the reader has to read the whole statement to find out that it does not matter.
To fix, remove it, or use it.
Example
Section titled “Example”...select a from t join u on t.a = u.a join v on t.a = v.b;with a as (select 1), b as (select 2), c as (select * from a) select * from c;with recursive r as (select 1 union all select n from r) select 2;Configuration
Section titled “Configuration”sql: lint: rules: unused-cte: warn # off, warn (default), errorEnabled by the presets: sql/sqlfluff.
Suppress one line with sudsy-disable-next-line unused-cte 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 | ST03 |
full |