【问题标题】:Google Dataflow: how to insert RECORD non-repeated type field to Big Query?Google Dataflow:如何将 RECORD 非重复类型字段插入 Big Query?
【发布时间】:2019-10-27 22:23:33
【问题描述】:

我是 Dataflow 的新手。我有一个预定义的模式,其中包含一个名为“设备”的非重复记录字段:

device.configId: STRING
device.version: STRING

使用 ParDo 转换,我尝试使用这种字段插入 TableRow,如下所示:

TableRow row = new TableRow();
row.put("field1", "val1");
TableRow device = new TableRow();
device.put("configId", "conf1");
device.put("version", "1.2.3");
row.put("device", device);
out.output(row);

我记录了表格行,它看起来像这样:

{field1=val1, device={configId=conf1, version=1.2.3}}

我将其输出到标准转换:BigQueryIO.write()

但后者发出错误:

java.lang.RuntimeException: java.io.IOException:
Insert failed: [{"errors":[{
    "debugInfo":"",
    "location":"device.configid",
    "message":"This field is not a record.",
    "reason":"invalid"
}],"index":0}]

不知道为什么,但请注意位置拼写为小写的“configid” - 而不是原始日志中的驼峰式拼写。

关于如何将此类对象插入 BigQuery 的任何想法?

【问题讨论】:

    标签: google-bigquery google-cloud-dataflow apache-beam


    【解决方案1】:

    发现问题。显然,仅当“configId”字段设置为 null 而不是“conf1”时才会出现此错误消息。确切地说,它被隐式设置为来自某个输入对象的 JSONObject.NULL。

    【讨论】:

      猜你喜欢
      • 2016-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-19
      • 2018-03-04
      相关资源
      最近更新 更多