You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rule L045 incorrectly raises an exception when a CTE is used in a correlated subquery in the WHERE clause. Here's an example of one such query that results in this false positive:
WITH max_date_cte AS (
SELECTMAX(row_updated_date) AS max_date
FROMwarehouse.loaded_monthly
)
SELECT stuff
FROMwarehouse.updated_weeklyWHERE row_updated_date <= (SELECT max_date FROM max_date_cte);
Expected Behaviour
I expect running sqlfluff lint on the query above to return with exit code 0 (no linting failure).
Observed Behaviour
Running sqlfluff lint on the query above results in a failure state, failing rule L045.
Steps to Reproduce
To quickly reproduce the error in bash:
q=$'WITH mycte AS (\n SELECT MAX(col1) AS maxdate\n FROM loaded_monthly\n)\n\nSELECT stuff\nFROM loaded_weekly\nWHERE row_updated_date <= (SELECT maxdate FROM mycte);'echo"$q"| sqlfluff lint - --rules L045
== [stdin] FAIL
L: 1 | P: 1 | L045 | Query defines a CTE (common-table expression) but does
| not use it
Rule
L045
incorrectly raises an exception when a CTE is used in a correlated subquery in theWHERE
clause. Here's an example of one such query that results in this false positive:Expected Behaviour
I expect running
sqlfluff lint
on the query above to return with exit code 0 (no linting failure).Observed Behaviour
Running
sqlfluff lint
on the query above results in a failure state, failing rule L045.Steps to Reproduce
To quickly reproduce the error in bash:
Version
Configuration
None (default)
The text was updated successfully, but these errors were encountered: