BigQuery向列表模式添加列 [英] Bigquery add columns to table schema
问题描述
我正在尝试向BigQuery现有表添加新列。我尝试过bq命令工具和API方法。调用Tables.update()时出现以下错误。
我试着提供完整的模式和附加字段,这也给了我同样的错误,如下所示。
使用API我得到以下错误:
{
schema:{
fields: [
{
name:added_column,
type:integer,
mode:nullable
}
]
错误:{
errors:[
{
domain]
{ :全球,
原因:无效,
消息:提供的架构不匹配表[blah]
}
],
代码:400,
消息:提供的模式不匹配表[blah]
}
}
使用BQ工具时,出现以下错误:
./bq update -t blah added_column:integer
<更新操作中的BigQuery错误:提供的Schema不匹配Table [blah]
试试这个:
bq --format = prettyjson show yourdataset.yourtable> table.json
编辑table.json并删除除fields之外的所有内容(例如,保留 [{name:x...},...]
)。然后将新字段添加到模式。
或者通过 jq
bq --format = prettyjson显示yourdataset.yourtable | jq .schema.fields> table.json
然后执行:
bq更新yourdataset.yourtable table.json
您可以添加 - apilog = apilog.txt
到命令行的开头,它将显示从bigquery服务器发送/返回的内容。
I am trying to add new column to BigQuery existing table. I have tried bq command tool and API approach. I get following error when making call to Tables.update().
I have tried with providing full schema with additional field and that also gives me same error as shown below.
With API I get following Error:
{
"schema": {
"fields": [
{
"name": "added_column",
"type": "integer",
"mode": "nullable"
}
]
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Provided Schema does not match Table [blah]"
}
],
"code": 400,
"message": "Provided Schema does not match Table [blah]"
}
}
With BQ tool I get following error: ./bq update -t blah added_column:integer
BigQuery error in update operation: Provided Schema does not match Table [blah]
Try this:
bq --format=prettyjson show yourdataset.yourtable > table.json
Edit table.json and remove everything except the inside of "fields" (e.g. keep the [ { "name": "x" ... }, ... ]
). Then add your new field to the schema.
Or pipe through jq
bq --format=prettyjson show yourdataset.yourtable | jq .schema.fields > table.json
Then run:
bq update yourdataset.yourtable table.json
You can add --apilog=apilog.txt
to the beginning of the command line which will show exactly what is sent / returned from the bigquery server.
这篇关于BigQuery向列表模式添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!