Bigquery add columns to table schema

前端 未结 5 2052
-上瘾入骨i
-上瘾入骨i 2020-12-01 10:50

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().

5条回答
  •  无人及你
    2020-12-01 11:48

    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.

提交回复
热议问题