Echo
Echo

Reputation: 405

How to add description to an existing bigquery table?

I'm looking for a way to add description to an existing table attributes, is there any simple command line command such as "alter table zzz add description...." to to this?

Upvotes: 4

Views: 4471

Answers (2)

Sheldon
Sheldon

Reputation: 166

Google has a new API, Google.Cloud.BigQuery.V2, which is available through NuGet. Updating the table description using the new API can be done as follows:

// instantiate a client for big query
// depending on the API version, this will be either BigqueryClient or BigQueryClient
BigqueryClient bqClient = BigqueryClient.Create(projectId, credential);

// get an instance of the tables resource using the client
TablesResource resource = new TablesResource(bqClient.Service);

// get the table definition from big query
TablesResource.GetRequest get = resource.Get(projectId, datasetId, tableId);
Table tbl = get.Execute();

// set the description property
tbl.Description = "New Description";

// save the changes to the table definition
TablesResource.PatchRequest patch = resource.Patch(tbl, projectId, datasetId, tableId);
patch.Execute();

Upvotes: 0

Felipe Hoffa
Felipe Hoffa

Reputation: 59165

You can add descriptions to tables and its fields through the web UI - that would be the simplest way.

Also via the API, using this document endpoint with the PATCH() methos:

https://cloud.google.com/bigquery/docs/reference/v2/tables

description 
schema.fields[].description 

The bq command line tool can be used too:

bq update --description "My table" existing_dataset.existing_table

Upvotes: 5

Related Questions