tconbeer/sqlfmt

Add rule for: query defines a CTE (common-table expression) but does not use it.

Closed this issue · 0 comments

What
It would be nice if sqlfmt identifies CTEs that are not used in any from or join.
This would be implementing the rule L045 that Sqlfluff has.

Motivation
It is surprising how many times you find unused CTEs in code.
Especially when you develop following dbt practices, there are a lot of CTEs and sometimes by mistake you forget to change the reference, or you forget to delete it.