Bigquery 将列添加到表架构 [英] Bigquery add columns to table schema

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

问题描述

我正在尝试向 BigQuery 现有表添加新列.我尝试过 bq 命令工具和 API 方法.调用 Tables.update() 时出现以下错误.

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.

使用 API 我得到以下错误:

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]"
    }
}

使用 BQ 工具时出现以下错误:

With BQ tool I get following error:

./bq update -t blah added_column:integer

更新操作中的 BigQuery 错误:提供的架构与表不匹配 [blah]

推荐答案

试试这个:

bq --format=prettyjson show yourdataset.yourtable > table.json

编辑 table.json 并删除除字段"内部之外的所有内容(例如,保留 [ { "name": "x" ... }, ... ]).然后将您的新字段添加到架构中.

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.

或者通过jq

bq --format=prettyjson show yourdataset.yourtable | jq .schema.fields > table.json

然后运行:

bq update yourdataset.yourtable table.json

您可以将 --apilog=apilog.txt 添加到命令行的开头,这将准确显示从 bigquery 服务器发送/返回的内容.

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天全站免登陆