架构加载JSON数据谷歌大查询 [英] Schema to load json data to google big query

查看:134
本文介绍了架构加载JSON数据谷歌大查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这个项目有一个问题,我们正在做...



我试图将这个JSON解压到Google Big Query并且无法获得JSON票对象来自JSON输入的字段。我尝试了模式中的记录和字符串类型。

  {
votes:{
funny:10,
useful:10,
cool:10
},
user_id:OlMjqqzWZUv2-62CSqKq_A,
review_id:LMy8UOKOeh0b9qrz-s1fQA,
stars:4,
date:2008-07-02,
text:这是
type:review,
business_id:81IjU5L-t-QQwsE38C63hQ
}

另外,我无法从类别和邻域JSON数组的JSON数组中获取下面填充的表格?我的模式应该为这些输入做什么?在这种情况下,文档并没有太大的帮助,或者我没有在正确的地方寻找。

  {
business_id:Iu-oeVzv8ZgP18NIB0UMqg,
full_address:3320 S Hill St \ South South LA \LLos Angeles,CA 90007,
schools:[
南加州大学

开放:true,
类别:[
医疗中心,
健康和医疗

neighborhoods:[
东南洛杉矶

}

$ b

我能够获得常规字段,但这就是关于它的任何帮助!

解决方案

对于商业您似乎希望学校成为重复的领域。您的模式应该是:

 schema:{
fields:[
{
name:business_id,
type:string
}。
{
name:full_address,
type:string
},
{
name:schools ,
type:string,
mode:repeated
},
{
name:open,
type:boolean
}
]
}



<对于票> 看起来你想要记录。您的模式应该是:

 schema:{
fields:[
{
name:name,
type:string
}。
{
name:votes,
type:record,
fields:[
{
name :
type:integer,
},
{
name:useful,
type:integer

{
name:cool,
type:integer
}
]
} ,
]
}

来源


I have a question for the project that we are doing...

I tried to extract this JSON to Google Big Query and not able to get JSON votes Object fields from the JSON input. I tried the "record" and the "string" types in the schema.

{
    "votes": {
        "funny": 10,
        "useful": 10,
        "cool": 10
    },
    "user_id": "OlMjqqzWZUv2-62CSqKq_A",
    "review_id": "LMy8UOKOeh0b9qrz-s1fQA",
    "stars": 4,
    "date": "2008-07-02",
    "text": "This is what this 4-star bar is all about.",
    "type": "review",
    "business_id": "81IjU5L-t-QQwsE38C63hQ"
}

Also i am not able to get the tables populated from this below JSON for the categories and neighborhood JSON arrays? What should my schema be for these inputs? The docs didn't help much unfortunately in this case or maybe i am not looking at the right place..

{
    "business_id": "Iu-oeVzv8ZgP18NIB0UMqg",
    "full_address": "3320 S Hill St\nSouth East LA\nLos Angeles, CA 90007",
    "schools": [
        "University of Southern California"
    ],
    "open": true,
    "categories": [
        "Medical Centers",
        "Health and Medical"
    ],
    "neighborhoods": [
        "South East LA"
    ]
}

I am able to get the regular fields, but that's about it... Any help is appreciated!

解决方案

For business it seems you want schools to be a repeated field. Your schema should be:

"schema": {
    "fields": [
        {
            "name": "business_id",
            "type": "string"
        }.
        {
            "name": "full_address",
            "type": "string"
        },
        {
            "name": "schools",
            "type": "string",
            "mode": "repeated"
        },
        {
            "name": "open",
            "type": "boolean"
        }
    ]
}

For votes it seems you want record. Your schema should be:

"schema": {
    "fields": [
        {
            "name": "name",
            "type": "string"
        }.
        {
            "name": "votes",
            "type": "record",
            "fields": [
                {
                    "name": "funny",
                    "type": "integer",
                },
                {
                    "name": "useful",
                    "type": "integer"
                },
                {
                    "name": "cool",
                    "type": "integer"
                }
            ]
        },
    ]
}

Source

这篇关于架构加载JSON数据谷歌大查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆