Let's take the following query:
with main as (
    select "David" as name, ["Joan", "Rick"] as parents union all
    select "Kyle" as name, ["Cathy", "Rick"] as parents
)
select
    name, parent
from
    main 
    CROSS JOIN UNNEST(parents) as parent
My question is why the <table> CROSS JOIN UNNEST(field) only joins with the 'table-from-array' within that row, and not in the entire table. For example, why doesn't the query do this instead:
main
    `name`
    - David
    - Kyle
<derived_from_array>
   `parent`
    - Rick
    - Joan
    - Cathy
    - Rick
Or, put another way, why doesn't the end-query do this:
with main as (
    select "David" as name union all
    select "Kyle" as name
),
derived_from_array as (
    select "Rick" as parent union all
    select "Joan" as parent union all
    select "Cathy" as parent union all
    select "Rick" as parent
)
select
    name, parent
from
    main 
    CROSS JOIN derived_from_array
In other words, how does it know to build the table-from-array only within that row ?


 
     
    