Site icon Insurance Biz

Insert into Nested records in Bigquery

Iam using Bigquery to insert nested records into the table but eventually landed into error scenario.

Schema:

 FieldName                  Type          Mode
 User                       STRING       NULLABLE
 Address                    RECORD       REPEATED
 Address.Name               STRING       NULLABLE
 Address.Age                STRING       NULLABLE
 Address.Details            RECORD       NULLABLE
 Address.Details.line1      STRING       NULLABLE
 Address.Details.line2      STRING       NULLABLE

Code:

INSERT  INTO `<dataset.tablename>`(User, Address)
values('newuser',
   [STRUCT('err' as Name,'24' as Age),
   STRUCT('newerr' as Name,'25' as Age)],
   STRUCT('streetname' as line1),
   STRUCT('houseno.' as line2)
  );

with the above code, I couldn’t able to load the values into table. Please help me by letting know how exactly we can pass values into nested records.

Exit mobile version