是否可以从UI向bigquery中的RECORD类型的现有字段添加新字段? [英] Is it possible to add a new field to an existing field of RECORD type in bigquery from UI?
问题描述
是否可以在bigquery中将新字段添加到RECORD类型的现有字段中?例如,如果我当前的模式是:
Is it possible to add a new field to an existing field of RECORD type in bigquery? So for example if my current schema is :
{u'fields': [{u'mode': u'NULLABLE', u'name': u'test1', u'type': u'STRING'},
{u'fields': [{u'mode': u'NULLABLE',
u'name': u'field1',
u'type': u'STRING'}],
u'mode': u'NULLABLE',
u'name': u'recordtest',
u'type': u'RECORD'}]}
我可以更改它以将字段"field2"添加到recordtest吗?因此,新架构将如下所示:
Can I change it to add field "field2" to recordtest? So the new schema will look like:
{u'fields': [{u'mode': u'NULLABLE', u'name': u'test1', u'type': u'STRING'},
{u'fields': [{u'mode': u'NULLABLE',
u'name': u'field1',
u'type': u'STRING'},
{u'mode': u'NULLABLE',
u'name': u'field2',
u'type': u'STRING'}],
u'mode': u'NULLABLE',
u'name': u'recordtest',
u'type': u'RECORD'}]}
我找不到从UI执行此操作的方法.但是我可以使用API来做到这一点.
I couldn't find a way to do this from the UI. But I was able to do this using the API.
推荐答案
完全可以使用相应的API资源管理器从UI内完成
This can be done totally from within UI using respective API Explorers
首先,您需要获取表的架构.您可以使用 Tables.get API资源管理器.确保在fields
框中选择/选中架构(最好不要选中其余的架构).单击Authorize and Execute
.完成后-复制回复文字-如下所示
First, you need to get schema of your table. You can do this using Tables.get API Explorer. Make sure you select/check schema in fields
box (better to leave the rest unchecked). Click Authorize and Execute
. When done - Copy response text - it will look somehow like below
{
"schema": {
"fields": [
{
"name": "id",
"type": "STRING",
"mode": "NULLABLE"
},
...
{
"name": "comment",
"type": "STRING",
"mode": "NULLABLE"
}
]
}
}
然后,使用 Tables.patch API资源管理器
将所需的字段添加到以前检索的架构中,然后将其按原样粘贴到Patch Body
框中(选择此框右上角的自由格式编辑器,然后用架构的文本替换其中的任何内容).再次单击Authorize and Execute
Then, use Tables.patch API Explorer
Add needed fields(s) into previously retrieved schema and paste it as is into Patch Body
box (chose freeform editor in the right-top corner of this box and just replace whatever inside with your schema's text). Again click Authorize and Execute
您现在完成了.
请注意,无论您将新字段放在记录中的何处-它将被添加到该记录字段的末尾
You done now.
Note that no matter where you put your new field within record - it will be added to the end of this record fields
顺便说一句,或者,您可以使用独立的资源管理器
服务> BigQuery API v2
Btw, alternatively, you can use standalone Explorers
Services > BigQuery API v2
我们在这里使用的是bigquery.jobs.get
和bigquery.tables.patch
The ones that we used here are bigquery.jobs.get
and bigquery.tables.patch
这篇关于是否可以从UI向bigquery中的RECORD类型的现有字段添加新字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!