【问题标题】:Insert into Nested records in Bigquery在 Bigquery 中插入嵌套记录
【发布时间】:2021-12-28 02:24:12
【问题描述】:

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

架构:

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

使用上面的代码,我无法将值加载到表中。请告诉我我们如何将值准确地传递到嵌套记录中来帮助我。

【问题讨论】:

    标签: sql google-bigquery


    【解决方案1】:

    改为下面试试

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

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 2021-12-04
      • 1970-01-01
      相关资源
      最近更新 更多