0
我有一個表不斷地接收流式插入(可能每秒數千)。流式插入時更新表模式
我有興趣使用更新功能(通過API調用)添加一列。我可以撥打Update將數據列添加到現有表中,而數據仍在插入中,而不用擔心丟失數據?
供參考,在這裏是我使用的列添加到表規劃代碼:
func addColumnToTable(service *bigquery.Service, project, dataset, table string, newCols map[string]string) bool {
resp, err := service.Tables.Get(project, dataset, table).Do()
if err != nil {
fmt.Println(err)
return false
}
for col, col_type := range newCols {
this_col := &bigquery.TableFieldSchema{}
this_col.Name = col
this_col.Type = col_type
resp.Schema.Fields = append(resp.Schema.Fields, this_col)
}
_, err = service.Tables.Update(project, dataset, table, resp).Do()
if err != nil {
fmt.Println(err)
return false
}
return true
}