2014-09-03 30 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