11 May 20 · npack · #Bigquery ·   Bookmark   ×

How to Add New Columns to a Table in Google BigQuery

If you have to add a new column to a table in Google Bigquery, you can use one of the below methods,

Adding a Column via the WebUI

Adding a column through the BigQuery WebUI is a very simple process:

  • Launch the BigQuery WebUI.
  • Select the project, dataset, and finally table you wish to alter.
  • Click the Add New Fields button.
  • For each field you wish to add, enter the name, select the type, and alter the mode (if necessary).
  • Once complete, click the Add to Table button to finalize your updates

Adding a Column using the Bigquery CLI (Command line Interface)

To update a table and add a new column using the BigQuery API, you have two options for which method to utilize: Tables.patch or Tables.update. Tables.patch only updates the fields that are added/modified, whereas Tables.update replaces the entire table resource with the new schema you provided. Lets look at an example for Tables.update API

First download the JSON definition:

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

Edit the JSON to include the new columns, once you are ready, run:

bq update yourdataset.yourtable table.json


posted on 11 May 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds