插入 Bigquery 中的嵌套记录

Insert into Nested records in Bigquery

我正在使用 Bigquery 将嵌套记录插入 table,但最终陷入错误场景。

架构:

 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

代码:

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)
  );

使用上面的代码,我无法将值加载到 table。请帮助我了解我们如何将值传递到嵌套记录中。

试试下面的方法

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