我已將數(shù)據(jù)從數(shù)據(jù)存儲導(dǎo)出到云存儲,并將其加載到BigQuery。如果我更改了架構(gòu)的順序,它會影響數(shù)據(jù)嗎?下表如下:用于更新架構(gòu)的代碼:func updateSchema(projectID, datasetID, tableID string) error { projectID := "my-project-id" datasetID := "mydataset" tableID := "mytable" ctx := context.Background() client, err := bigquery.NewClient(ctx, projectID) if err != nil { return fmt.Errorf("bigquery.NewClient: %v", err) } defer client.Close() tableRef := client.Dataset(datasetID).Table(tableID) meta, err := tableRef.Metadata(ctx) if err != nil { return err } newSchema := bigquery.Schema{ {Name: "settlement", Type: bigquery.StringFieldType }, {Name: "dismissal_id", Type: bigquery.IntegerFieldType }, {Name: "brand_safe_flag", Type: bigquery.BooleanFieldType }, {Name: "net_cv_cost", Type: bigquery.StringFieldType }, {Name: "gross_cv_cost", Type: bigquery.StringFieldType }, {Name: "non_achievement_message", Type: bigquery.StringFieldType }, {Name: "partner_id", Type: bigquery.IntegerFieldType }, {Name: "click_url", Type: bigquery.RecordFieldType, Schema: bigquery.Schema{ {Name: "string", Type: bigquery.StringFieldType}, {Name: "text", Type: bigquery.StringFieldType}, {Name: "provided", Type: bigquery.StringFieldType}, }}, } update := bigquery.TableMetadataToUpdate{ Schema: newSchema, } if _, err := tableRef.Update(ctx, update, meta.ETag); err != nil { return err } return nil}
1 回答

LEATH
TA貢獻1936條經(jīng)驗 獲得超7個贊
現(xiàn)有 BigQuery 表支持的唯一修改是:
向架構(gòu)定義中添加列
將列的模式從 放寬為
REQUIRED
NULLABLE
請參閱 https://cloud.google.com/bigquery/docs/managing-table-schemas。如果要在這兩個操作的范圍之外執(zhí)行架構(gòu)更改,則可能必須采用其他方法。請考慮將數(shù)據(jù)遷移到具有新架構(gòu)的新表中。
- 1 回答
- 0 關(guān)注
- 206 瀏覽
添加回答
舉報
0/150
提交
取消