2014-09-03 53 views
2

任何相关的帮助将不胜感激。在线生成的架构定义在使用负载表API时,BigQuery不接受架构生成器

我有几个不同的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

这并不是看所有的BigQuery模式,它是其他模式,你感到困惑。你使用了什么发电机? – Pentium10 2014-09-03 11:18:10

+0

@Pentium 10 - 你可能没有仔细阅读我的问题。我在这里打印的模式是从联机Json模式生成器生成的。这是有效的。但是BigQuery不接受这种格式。现在是在这里的任何工具或实用程序,根据BigQuery可接受的格式生成模式? – Subhayu 2014-09-03 12:30:25

+0

什么是错误? – Mario 2014-09-03 13:27:04

回答

2

该工具生成的模式比BigQuery需要的模式复杂得多。

看在文档样本:

"schema": { 
     "fields": [ 
      {"name":"f1", "type":"STRING"}, 
      {"name":"f2", "type":"INTEGER"} 
     ] 
     }, 

https://developers.google.com/bigquery/loading-data-into-bigquery?hl=es#loaddatapostrequest

与此同时,在问题中提到的工具将像$架构,描述,类型,所需的字段,这是没有必要的性质并混淆了BigQuery模式解析器。

+0

谢谢大家!我已经完成BigQuery加载,但只有我想从这个论坛中知道的事情,如果有人可以指向BigQuery架构的任何自动生成器工具。 – Subhayu 2014-09-04 05:33:03

+0

@Subhayu据我们所知,BQ模式没有自动生成工具,模式非常独特,你不需要它们。创建甚至用手写json模式非常简单。 – Pentium10 2014-09-08 19:13:02

+0

incase其他人正在寻找 - https://bigquery-json-schema-generator.com/ – 2017-09-21 15:58:06