Replies: 3 comments 7 replies
-
What SQLGlot version are you currently using? I'm getting a different behavior locally (v10.2.9): >>> import sqlglot
>>> sql = """
... SELECT
... tbl1.field1
... FROM tbl1
... LEFT JOIN LATERAL (
... SELECT
... tbl2.field1
... FROM tbl2
... WHERE 1=1
... AND tbl2.field1 = tbl1.field1
... ) tbl2
... LEFT JOIN tbl3
... ON tbl3.field1 = tbl2.field1
... """
>>>
>>> print(sqlglot.transpile(sql, pretty=True)[0])
SELECT
tbl1.field1
FROM tbl1
LEFT JOIN LATERAL (
SELECT
tbl2.field1
FROM tbl2
WHERE
1 = 1 AND tbl2.field1 = tbl1.field1
) AS tbl2
LEFT JOIN tbl3
ON tbl3.field1 = tbl2.field1 |
Beta Was this translation helpful? Give feedback.
7 replies
-
Ah found the problem btw @georgesittas regarding the order of laterals/joins. This is only currently occuring if the read dialect has the CROSS/OUTER APPLY. As the join class is being returned from the parse_lateral, therefore it is currently not beeing registered as a join at the select class and ends up at the end of the query modifiers. Ill send in a fix for this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
Im currently dealing with issues regarding the order of query modifiers.
Take for example this example in mind:
However the output currently outputs the joins first and then the laterals:
I was thinking of introducting an attribute "position" in both the laterals as well as the joins and sort the list when beeing outputted in the generator. The other way could be to have only "joins" for example, but that would require quite some rework i think. What do you guys think would be the best approach to fix this?
Beta Was this translation helpful? Give feedback.
All reactions