Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bigquery): add table resource tags support (#9084)
This PR adds support for resource tags on BigQuery tables. Due to the nature of the feature, testing necessitates special provisioning with resourcemanager to establish a parent with the proper keys and values defined, which can then be bound to the table. While implementing, testing was done in a personal test project, with the following commands to establish the necessary tags/values: ``` gcloud resource-manager tags keys create test_tag_key --parent=projects/shollyman-testing gcloud resource-manager tags values create COFFEE --parent=tagKeys/281483438148747 gcloud resource-manager tags values create TEA --parent=tagKeys/281483438148747 gcloud resource-manager tags values create WATER --parent=tagKeys/281483438148747 ``` This integration test was used to smoke test that the feature works: ``` func TestIntegration_TableResourceTags(t *testing.T) { if client == nil { t.Skip("Integration tests skipped") } testKey := "shollyman-testing/test_tag_key" ctx := context.Background() table := dataset.Table(tableIDs.New()) resourceTags := map[string]string{ testKey: "COFFEE", } if err := table.Create(context.Background(), &TableMetadata{ Schema: schema, ResourceTags: resourceTags, }); err != nil { t.Fatalf("table.Create: %v", err) } defer table.Delete(ctx) md, err := table.Metadata(ctx) if err != nil { t.Fatalf("table.Metadata: %v", err) } var found bool for k, v := range md.ResourceTags { if k == testKey && v == "COFFEE" { found = true break } } if !found { t.Errorf("tag key/value not found") } updatedTags := map[string]string{ testKey: "COFFEE", } // Update table DefaultCollation to case-sensitive updated, err := table.Update(ctx, TableMetadataToUpdate{ ResourceTags: updatedTags, }, md.ETag) if err != nil { t.Fatalf("table.Update: %v", err) } found = false for k, v := range updated.ResourceTags { if k == testKey && v == "COFFEE" { found = true break } } if !found { t.Errorf("tag key/value not found") } } ``` I've removed the integration test for the time being after verification, given the complexity of the setup outside of the BQ service.
- Loading branch information