从bigquery WebUI将jSON加载到bigquery表时,在模式中定义数组

时间:2015-01-14 07:52:52

标签: json google-bigquery google-cloud-platform

我正在将json文件加载到bigquery数据集中的表中。该文件中的示例json是:

{"a": "string_a","b": "string_b","c": 4.42,"d_list":["x","y","z"]}

我将架构字段定义为:

a:string, b:string, c:float, d_list:string

这会导致导入错误Field:d_list, array specified for non-repeated field

我认为d_list应定义为:

  {
    "type": "STRING",
    "name": "d_list",
    "mode": "repeated"
  }

是不是?如果是,我如何使用WEbUI以这种方式定义它?

1 个答案:

答案 0 :(得分:3)

Web UI也接受帮助器图标中所述的JSON行,因此您可以将JSON数组定义为字段,并将其粘贴到Web UI中。

[
{
    "type": "STRING",
    "name": "a",
    "mode": "nullable"
},
{
    "type": "STRING",
    "name": "b",
    "mode": "nullable"
},
{
    "type": "FLOAT",
    "name": "c",
    "mode": "nullable"
},
{
    "type": "STRING",
    "name": "d_list",
    "mode": "repeated"
}
]