如何向现有的bigquery表添加描述?

时间:2015-04-15 20:49:38

标签: google-bigquery

我正在寻找一种方法来向现有的表属性添加描述,是否有任何简单的命令行命令,例如" alter table zzz add description ...."对此?

2 个答案:

答案 0 :(得分:2)

您可以通过Web UI向表及其字段添加说明 - 这是最简单的方法。

同样通过API,将此文档端点与PATCH()方法一起使用:

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

description 
schema.fields[].description 

也可以使用bq命令行工具:

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

答案 1 :(得分:0)

Google推出了新的API,即Google.Cloud.BigQuery.V2,可通过NuGet获取。使用新API更新表描述可以按如下方式完成:

// 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();