ccao-data / data-architecture

Codebase for CCAO data infrastructure construction and management
https://ccao-data.github.io/data-architecture/
6 stars 4 forks source link

Add custom SQLFluff rule to disallow trailing semicolons in models #642

Open jeancochrane opened 1 week ago

jeancochrane commented 1 week ago

As we've discovered, trailing semicolons can cause problems in dbt models. This is because dbt occasionally composes model definitions using CTEs, and if a model includes a semicolon it can erroneously indicate to the SQL interpreter that the statement has ended.

It appears that there is no SQLFluff rule to disallow trailing semicolons, and in fact, there is instead a rule to enforce trailing semicolons. However, I think it would be a fun exercise to create a custom rule to catch this case.