BigQuery向列表模式添加列 [英] Bigquery add columns to table schema

查看:99
本文介绍了BigQuery向列表模式添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向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屋!

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