Skip to content
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

2.0.0a2 Comment in a complex, nested sub-query breaks indentation of following SQL #4252

Closed
2 of 3 tasks
dmohns opened this issue Jan 9, 2023 · 0 comments · Fixed by #4285
Closed
2 of 3 tasks

2.0.0a2 Comment in a complex, nested sub-query breaks indentation of following SQL #4252

dmohns opened this issue Jan 9, 2023 · 0 comments · Fixed by #4285
Labels
bug Something isn't working

Comments

@dmohns
Copy link
Contributor

dmohns commented Jan 9, 2023

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Took me a while to figure out what the issue here was, probably there is a simpler MWE, but I was only able reproduce it in this specific scenario.

Sometimes a comment can cause problems with following indentation. Consider the following example, everything after the comment has 1 indent too much

WITH cte AS (
    SELECT *
    FROM (
        SELECT *
        FROM table
        WHERE
            NOT bool_column AND NOT bool_column
            AND some_column >= 1  -- This is a comment
        )
    ),

    SELECT *
    FROM cte
;

    SELECT *
    FROM table3
;

However, if I remove the comment everything gets linted correctly

WITH cte AS (
    SELECT *
    FROM (
        SELECT *
        FROM table
        WHERE
            NOT bool_column AND NOT bool_column
            AND some_column >= 1
    )
),

SELECT *
FROM cte
;

SELECT *
FROM table3
;

Expected Behaviour

see above

Observed Behaviour

see above

How to reproduce

see above

Dialect

BigQuery

Version

sqlfluff, version 2.0.0a2

Configuration

default

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@dmohns dmohns added the bug Something isn't working label Jan 9, 2023
alanmcruickshank added a commit that referenced this issue Jan 15, 2023
alanmcruickshank added a commit that referenced this issue Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant