I am trying to load data from one table with nested multi-valued column to another table with the same schema, but with one or fields less.
Table-1 Schema:
Person RECORD REPEATED ;
Person.Address RECORD REPEATED ;
Person.Address.phone INTEGER NULLABLE ;
Person.Address.zip INTEGER NULLABLE ;
Person.flag INTEGER ;
Wt INTEGER ;
Table-2 Schema:
Person RECORD REPEATED ;
Person.Address RECORD REPEATED ;
Person.Address.phone INTEGER NULLABLE ;
Person.flag INTEGER ;
Wt INTEGER ;
Please note that the only difference between these two tables is that Table-2 does not have the "zip" field.
I am trying to load Table-2 from Table-1 using the below query:
INSERT INTO TABLE-2
SELECT
ARRAY (SELECT AS STRUCT (ARRAY (SELECT AS STRUCT (SELECT PA.phone from unnest (P.Address) as
PA)), P.flag) from unnest(Table-1.Person) as P), s.Wt
from Table-1
This always throws the below error: "Query column 1 has type ARRAY>, INT64>>> which cannot be inserted into column Person, which has type ARRAY>, flag INT64>> at [2:1]"
If you look at the query, it exactly matches with that of the target column. Any idea on what is going wrong?