LT02 forces a line break before `LATERAL` keyword of the first lateral join only when a second sibling join follows it
Search before asking
- I searched the issues and found no similar issues.
What Happened
When a FROM clause's bracketed subquery is followed by 2+ consecutive CROSS JOIN LATERAL clauses, LT02 requires the first LATERAL to be pushed onto its own indented line, but has no complaint about the second one staying on the same line as CROSS JOIN. If only one JOIN LATERAL clause is present, it's allowed to stay on one line with no violation at all.
The content of the two join clauses doesn't matter -- swapping which one comes first just moves the forced break to whichever one is now first.
Expected Behaviour
CROSS JOIN LATERAL stays on the same line regardless of how many such statements are present.
Observed Behavior
Keyword LATERAL of the first join is pushed to the next line with subsequent clause contents indented.
How to reproduce
Lint is passed with single join:
SELECT *
FROM (
SELECT 1 AS id
) t
CROSS JOIN LATERAL (
SELECT 1 AS x
) a$ sqlfluff lint --dialect postgres min_single.sql --rules LT02
All Finished!List isn't passed with multiple joins:
SELECT *
FROM (
SELECT 1 AS id
) t
CROSS JOIN LATERAL (
SELECT 1 AS x
) a
CROSS JOIN LATERAL (
SELECT 1 AS y
) b$ sqlfluff lint --dialect postgres min.sql --rules LT02
L: 5 | P: 15 | LT02 | Expected line break and indent of 8 spaces before
| 'LATERAL'. [layout.indent]
L: 6 | P: 1 | LT02 | Expected indent of 12 spaces. [layout.indent]
L: 7 | P: 1 | LT02 | Expected indent of 8 spaces. [layout.indent]Dialect
postgres
Version
sqlfluff: 4.2.2 Python: 3.12.10
Configuration
[sqlfluff]
dialect = postgres
[sqlfluff:indentation]
indented_joins = TrueAre you willing to work on and submit a PR to address the issue?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: sqlfluff/sqlfluff