New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CTE with column names is handled incorrectly in lint and fix #2136
Comments
coolio, can fix this pretty easily 👍 |
Sorry to report on a closed ticket, but this doesn't seem to have made it into 1.0.0:
Test file WITH
cte_1 AS (
SELECT 1 AS var
),
cte_2 (var) AS (
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2; |
It looks related but slightly different. This issue fixed the original test case, and also fixes yours if the (var) is set on cte_1 but not for cte_2. Let's keep this closed, and can you open a new issue for that? Link to this Issue and PR #2139 in that. |
CTEs with column name definitions can be parsed, but linting rules aren't able to handle the column names, and instead seem to treat them as if they were the actual query / table expression. There's some discussion in #345 -- it looks like that issue was about sqlfluff not being able to parse this construction.
Expected Behaviour
Given the following input (this is cleaned up from the recursive example in the postgresql docs)
sqlfluff lint
should report no errors, andsqlfluff fix
should make no changes.Observed Behaviour
sqlfluff parse output
Dialect
postgres, but as noted in #345 this isn't postgres-specific
Version
Configuration
default
Thanks!
The text was updated successfully, but these errors were encountered: