PostgreSQL json_array_elements in FROM section - why is this not a Cartesian join?

If I have an expression like

SELECT t.json_column->>'x',
   nested->>'y'
FROM my_table t,
   json_array_elements(t->'nested') nested

Why don't I need a JOIN? More precisely, why does this not act as Cartesian CROSS JOIN?

It appears that the join is implicit, referring to the table alias tin the call json_array_elements. But the implicit-join syntax with the table function is unfamiliar to me.

Are there other examples of similar SQL syntax in PostgreSQL or other databases?

+4
source share
1 answer

This is actually an old-fashioned syntax for CROSS JOIN. Formal equivalent:

SELECT
    t.json_column->>'x',
    nested->>'y'
FROM 
    my_table t
CROSS JOIN
    json_array_elements(t.json_column->'nested') nested;

, . , , t. LATERAL JOIN. :

FROM LATERAL , : FROM, FROM, , LATERAL item . , , , . () .

, .

+4

Source: https://habr.com/ru/post/1614357/


All Articles