Schema to load json data to google big query
google-bigquery, json
Solution
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
Problem
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!