任何相关的帮助将不胜感激。
我有几个不同的JSON文档需要插入到BigQuery中。现在为了避免手动生成模式,我使用了在线Json模式生成工具的帮助。但是BigQuery Load Data向导不接受它们生成的模式。 对于eaxmple:对于像这样的Json数据:
{"_id":100,"actor":"KK","message":"CCD is good in Pune",
"comment":[{"actor":"Subho","message":"CCD is not as good in Kolkata."},
{"actor":"bisu","message":"CCD is costly too in Kolkata"}]
}
在线工具生成的架构是:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Generated from c:jsonccd.json with shasum a003286a350a6889b152
b3e33afc5458f3771e9c",
"type": "object",
"required": [
"_id",
"actor",
"message",
"comment"
],
"properties": {
"_id": {
"type": "integer"
},
"actor": {
"type": "string"
},
"message": {
"type": "string"
},
"comment": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "object",
"required": [
"actor",
"message"
],
"properties": {
"actor": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
但是当我在加载数据向导中将它放入BigQuery时,它会失败并出现错误。
如何减轻这种情况?
感谢。
答案 0 :(得分:2)
该工具生成的模式比BigQuery要求的更复杂。
查看文档中的示例:
"schema": {
"fields": [
{"name":"f1", "type":"STRING"},
{"name":"f2", "type":"INTEGER"}
]
},
https://developers.google.com/bigquery/loading-data-into-bigquery?hl=es#loaddatapostrequest
同时,问题中提到的工具添加了诸如 $ schema,description,type,required,properties 之类的字段,这些字段对于BigQuery模式解析器来说并不是必需和混淆。