I found lots of example to create nested data in google bigquery manual but there is no example to do this from another tables.
I want to create a new table (for example solar_system_moons_nested) with nested data (write SQL statement to generate the nested data) using two existing tables (for example planets and moons tables). I want the new table look as follows:
I create the moon and planet tables as below:
- moon table
- planet table:
Is there anyway to create a nested table from existing tables? any help would be appreciated.
Here is how I made the new table(as below):
WITH solar_system_moons_nested AS (
SELECT p.planet,
STRUCT(moon ,Distance_from_Planet__km_,Diameter__km_) AS moons,
from test.planets p inner join test.moons m on m.planet=p.planet
)
select * from solar_system_moons_nested
As you see, the select did not do what I expected.



