Skip to content

unused-cte

SQLsuspiciousno fixdefault: warnsql/sqlfluff

Reports a common table expression that nothing in the WITH statement refers to.

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.

Reported
...
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;
sql:
lint:
rules:
unused-cte: warn # off, warn (default), error

Enabled by the presets: sql/sqlfluff.

Suppress one line with sudsy-disable-next-line unused-cte in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
sqlfluff ST03 full