tconbeer / sqlfmt

sqlfmt formats your dbt SQL files so you don't have to
https://sqlfmt.com
Apache License 2.0
373 stars 15 forks source link

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

Closed rloredo closed 8 months ago

rloredo commented 8 months ago

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.